serenity/model/
connection.rs

1//! Models for user connections.
2
3use super::prelude::*;
4
5/// Information about a connection between the current user and a third party service.
6///
7/// [Discord docs](https://discord.com/developers/docs/resources/user#connection-object-connection-structure).
8#[derive(Clone, Debug, Deserialize, Serialize)]
9#[non_exhaustive]
10pub struct Connection {
11    /// The ID of the account on the other side of this connection.
12    pub id: String,
13    /// The username of the account on the other side of this connection.
14    pub name: String,
15    /// The service that this connection represents (e.g. twitch, youtube)
16    ///
17    /// [Discord docs](https://discord.com/developers/docs/resources/user#connection-object-services).
18    #[serde(rename = "type")]
19    pub kind: String,
20    /// Whether this connection has been revoked and is no longer valid.
21    #[serde(default)]
22    pub revoked: bool,
23    /// A list of partial guild [`Integration`]s that use this connection.
24    #[serde(default)]
25    pub integrations: Vec<Integration>,
26    /// Whether this connection has been verified and the user has proven they own the account.
27    pub verified: bool,
28    /// Whether friend sync is enabled for this connection.
29    pub friend_sync: bool,
30    /// Whether activities related to this connection will be shown in presence updates.
31    pub show_activity: bool,
32    /// Whether this connection has a corresponding third party OAuth2 token.
33    pub two_way_link: bool,
34    /// The visibility of this connection.
35    pub visibility: ConnectionVisibility,
36}
37
38enum_number! {
39    /// The visibility of a user connection on a user's profile.
40    ///
41    /// [Discord docs](https://discord.com/developers/docs/resources/user#connection-object-visibility-types).
42    #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
43    #[serde(from = "u8", into = "u8")]
44    #[non_exhaustive]
45    pub enum ConnectionVisibility {
46        /// Invisible to everyone except the user themselves
47        None = 0,
48        /// Visible to everyone
49        Everyone = 1,
50        _ => Unknown(u8),
51    }
52}