twilight_model/gateway/payload/outgoing/
identify.rs1use super::update_presence::UpdatePresencePayload;
2use crate::gateway::{Capabilities, ShardId, intents::Intents, opcode::OpCode};
3use serde::{Deserialize, Serialize};
4
5#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
6pub struct Identify {
7 pub d: IdentifyInfo,
8 pub op: OpCode,
9}
10
11impl Identify {
12 pub const fn new(info: IdentifyInfo) -> Self {
13 Self {
14 d: info,
15 op: OpCode::Identify,
16 }
17 }
18}
19
20#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
21pub struct IdentifyInfo {
22 pub capabilities: Capabilities,
23 pub compress: bool,
24 pub intents: Intents,
25 pub large_threshold: u64,
26 pub presence: Option<UpdatePresencePayload>,
27 pub properties: IdentifyProperties,
28 pub shard: Option<ShardId>,
29 pub token: String,
30}
31
32#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
33pub struct IdentifyProperties {
34 pub browser: String,
35 pub device: String,
36 pub os: String,
37}
38
39impl IdentifyProperties {
40 pub fn new(
41 browser: impl Into<String>,
42 device: impl Into<String>,
43 os: impl Into<String>,
44 ) -> Self {
45 Self {
46 browser: browser.into(),
47 device: device.into(),
48 os: os.into(),
49 }
50 }
51}