use std::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ChannelState {
Idle,
Connecting,
Connected,
Reconnecting,
Failed,
Closing,
Closed,
}
impl ChannelState {
pub fn as_str(self) -> &'static str {
match self {
ChannelState::Idle => "idle",
ChannelState::Connecting => "connecting",
ChannelState::Connected => "connected",
ChannelState::Reconnecting => "reconnecting",
ChannelState::Failed => "failed",
ChannelState::Closing => "closing",
ChannelState::Closed => "closed",
}
} }
impl fmt::Display for ChannelState {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(self.as_str())
} }
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MessageMetadata {
pub token_reference: String,
pub segment_id: String,
pub message_id: String,
pub timestamp: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ServerNotice {
pub timestamp: i64,
pub payload: Vec<u8>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PresencePage {
pub segment_id: String,
pub total: i32,
pub per_page: i32,
pub current_page: i32,
pub from: i32,
pub to: i32,
pub connections: Vec<PresenceConnection>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PresenceConnection {
pub token_reference: String,
pub connection_id: String,
pub timestamp: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PresenceEvent {
pub segment_id: String,
pub token_reference: String,
pub connection_id: String,
pub joined: bool,
pub timestamp: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RecoveryEvent {
pub retry_index: u32,
pub possible_gaps: bool,
pub possible_duplicates: bool,
}