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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
use super::update_status::UpdateStatusInfo; use crate::gateway::{intents::Intents, opcode::OpCode}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct Identify { pub d: IdentifyInfo, pub op: OpCode, } impl Identify { pub fn new(info: IdentifyInfo) -> Self { Self { d: info, op: OpCode::Identify, } } } #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct IdentifyInfo { pub compress: bool, pub intents: Intents, pub large_threshold: u64, pub presence: Option<UpdateStatusInfo>, pub properties: IdentifyProperties, pub shard: Option<[u64; 2]>, pub token: String, pub v: u64, } #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct IdentifyProperties { #[serde(rename = "$browser")] pub browser: String, #[serde(rename = "$device")] pub device: String, #[serde(rename = "$os")] pub os: String, #[serde(rename = "$referrer")] pub referrer: String, #[serde(rename = "$referring_domain")] pub referring_domain: String, } impl IdentifyProperties { pub fn new( browser: impl Into<String>, device: impl Into<String>, os: impl Into<String>, referrer: impl Into<String>, referring_domain: impl Into<String>, ) -> Self { Self { browser: browser.into(), device: device.into(), os: os.into(), referrer: referrer.into(), referring_domain: referring_domain.into(), } } }