twilight_model/user/
connection.rs1use crate::{guild::GuildIntegration, user::ConnectionVisibility};
2use serde::{Deserialize, Serialize};
3
4#[allow(clippy::struct_excessive_bools)]
5#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
6pub struct Connection {
7 pub friend_sync: bool,
8 pub id: String,
9 #[serde(default)]
10 pub integrations: Vec<GuildIntegration>,
11 #[serde(rename = "type")]
12 pub kind: String,
13 pub name: String,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub revoked: Option<bool>,
16 pub show_activity: bool,
17 pub two_way_link: bool,
19 pub verified: bool,
20 pub visibility: ConnectionVisibility,
21}
22
23#[cfg(test)]
24mod tests {
25 use super::{Connection, ConnectionVisibility};
26 use serde_test::Token;
27
28 #[test]
29 fn connection() {
30 let value = Connection {
31 friend_sync: true,
32 id: "connection id".to_owned(),
33 integrations: Vec::new(),
34 kind: "integration type".to_owned(),
35 name: "integration name".to_owned(),
36 revoked: Some(false),
37 show_activity: true,
38 verified: true,
39 two_way_link: false,
40 visibility: ConnectionVisibility::Everyone,
41 };
42
43 serde_test::assert_tokens(
44 &value,
45 &[
46 Token::Struct {
47 name: "Connection",
48 len: 10,
49 },
50 Token::Str("friend_sync"),
51 Token::Bool(true),
52 Token::Str("id"),
53 Token::Str("connection id"),
54 Token::Str("integrations"),
55 Token::Seq { len: Some(0) },
56 Token::SeqEnd,
57 Token::Str("type"),
58 Token::Str("integration type"),
59 Token::Str("name"),
60 Token::Str("integration name"),
61 Token::Str("revoked"),
62 Token::Some,
63 Token::Bool(false),
64 Token::Str("show_activity"),
65 Token::Bool(true),
66 Token::Str("two_way_link"),
67 Token::Bool(false),
68 Token::Str("verified"),
69 Token::Bool(true),
70 Token::Str("visibility"),
71 Token::U8(1),
72 Token::StructEnd,
73 ],
74 );
75 }
76}