twilight_model/gateway/presence/
activity_secrets.rs

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
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ActivitySecrets {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub join: Option<String>,
    #[serde(rename = "match", skip_serializing_if = "Option::is_none")]
    pub match_: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spectate: Option<String>,
}

#[cfg(test)]
mod tests {
    use super::ActivitySecrets;
    use serde_test::Token;

    #[test]
    fn activity_secrets() {
        let value = ActivitySecrets {
            join: Some("a".to_owned()),
            match_: Some("b".to_owned()),
            spectate: Some("c".to_owned()),
        };

        serde_test::assert_tokens(
            &value,
            &[
                Token::Struct {
                    name: "ActivitySecrets",
                    len: 3,
                },
                Token::Str("join"),
                Token::Some,
                Token::Str("a"),
                Token::Str("match"),
                Token::Some,
                Token::Str("b"),
                Token::Str("spectate"),
                Token::Some,
                Token::Str("c"),
                Token::StructEnd,
            ],
        );
    }
}