twilight_model/gateway/connection_info/
bot_connection_info.rsuse crate::gateway::SessionStartLimit;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct BotConnectionInfo {
pub session_start_limit: SessionStartLimit,
pub shards: u32,
pub url: String,
}
#[cfg(test)]
mod tests {
use super::{BotConnectionInfo, SessionStartLimit};
use serde_test::Token;
#[test]
fn connection_info() {
let value = BotConnectionInfo {
session_start_limit: SessionStartLimit {
max_concurrency: 16,
remaining: 998,
reset_after: 84_686_789,
total: 1000,
},
shards: 3,
url: "wss://gateway.discord.gg".to_owned(),
};
serde_test::assert_tokens(
&value,
&[
Token::Struct {
name: "BotConnectionInfo",
len: 3,
},
Token::Str("session_start_limit"),
Token::Struct {
name: "SessionStartLimit",
len: 4,
},
Token::Str("max_concurrency"),
Token::U16(16),
Token::Str("remaining"),
Token::U32(998),
Token::Str("reset_after"),
Token::U64(84_686_789),
Token::Str("total"),
Token::U32(1000),
Token::StructEnd,
Token::Str("shards"),
Token::U32(3),
Token::Str("url"),
Token::Str("wss://gateway.discord.gg"),
Token::StructEnd,
],
);
}
}