twilight_model/gateway/presence/
activity_secrets.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
4pub struct ActivitySecrets {
5    #[serde(skip_serializing_if = "Option::is_none")]
6    pub join: Option<String>,
7    #[serde(rename = "match", skip_serializing_if = "Option::is_none")]
8    pub match_: Option<String>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub spectate: Option<String>,
11}
12
13#[cfg(test)]
14mod tests {
15    use super::ActivitySecrets;
16    use serde_test::Token;
17
18    #[test]
19    fn activity_secrets() {
20        let value = ActivitySecrets {
21            join: Some("a".to_owned()),
22            match_: Some("b".to_owned()),
23            spectate: Some("c".to_owned()),
24        };
25
26        serde_test::assert_tokens(
27            &value,
28            &[
29                Token::Struct {
30                    name: "ActivitySecrets",
31                    len: 3,
32                },
33                Token::Str("join"),
34                Token::Some,
35                Token::Str("a"),
36                Token::Str("match"),
37                Token::Some,
38                Token::Str("b"),
39                Token::Str("spectate"),
40                Token::Some,
41                Token::Str("c"),
42                Token::StructEnd,
43            ],
44        );
45    }
46}