1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use crate::{id::RoleId, user::User};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct InviteStageInstance {
    /// Members speaking in the Stage.
    pub members: Vec<InviteStageInstanceMember>,
    /// Total number of users.
    pub participant_count: u64,
    /// Number of speakers.
    pub speaker_count: u64,
    /// Topic of the Stage instance.
    ///
    /// Between 1 and 120 characters.
    pub topic: String,
}

#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct InviteStageInstanceMember {
    /// Guild specific avatar hash.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avatar: Option<String>,
    /// ISO 8601 timestamp of the date the member joined the guild.
    pub joined_at: String,
    /// Member's nickname, if there is one.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub nick: Option<String>,
    /// Whether the member has passed the guild's membership screening requirements.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pending: Option<bool>,
    /// ISO 8601 timestamp of the date the member boosted the guild.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub premium_since: Option<String>,
    /// List of role IDs the user has.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub roles: Vec<RoleId>,
    /// User data for the member.
    pub user: User,
}

#[cfg(test)]
mod tests {
    use super::{InviteStageInstance, InviteStageInstanceMember};
    use serde::{Deserialize, Serialize};
    use static_assertions::{assert_fields, assert_impl_all};
    use std::{fmt::Debug, hash::Hash};

    assert_fields!(
        InviteStageInstance: members,
        participant_count,
        speaker_count,
        topic
    );

    assert_fields!(
        InviteStageInstanceMember: avatar,
        joined_at,
        nick,
        pending,
        premium_since,
        roles,
        user
    );

    assert_impl_all!(
        InviteStageInstance: Clone,
        Debug,
        Deserialize<'static>,
        Eq,
        Hash,
        PartialEq,
        Serialize,
        Send,
        Sync
    );

    assert_impl_all!(
        InviteStageInstanceMember: Clone,
        Debug,
        Deserialize<'static>,
        Eq,
        Hash,
        PartialEq,
        Serialize,
        Send,
        Sync
    );
}