use serde::Deserialize;
use serde::Serialize;
use super::ApplicationErrorCode;
use super::Bytes;
use super::ConnectionErrorCode;
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
#[serde(rename_all = "snake_case")]
pub enum TransportOwner {
Local,
Remote,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
#[serde(rename_all = "snake_case")]
pub enum ConnectionState {
Attempted,
PeerValidated,
HandshakeStarted,
EarlyWrite,
HandshakeCompleted,
HandshakeConfirmed,
Closing,
Draining,
Closed,
}
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
#[serde(rename_all = "snake_case")]
pub enum ConnectivityEventType {
ServerListening,
ConnectionStarted,
ConnectionClosed,
ConnectionIdUpdated,
SpinBitUpdated,
ConnectionStateUpdated,
MtuUpdated,
}
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
#[serde(rename_all = "snake_case")]
pub enum ConnectionClosedTrigger {
Clean,
HandshakeTimeout,
IdleTimeout,
Error,
StatelessReset,
VersionMismatch,
Application,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct ServerListening {
pub ip_v4: Option<String>, pub ip_v6: Option<String>, pub port_v4: Option<u16>,
pub port_v6: Option<u16>,
retry_required: Option<bool>,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct ConnectionStarted {
pub ip_version: Option<String>, pub src_ip: String, pub dst_ip: String, pub protocol: Option<String>,
pub src_port: Option<u16>,
pub dst_port: Option<u16>,
pub src_cid: Option<Bytes>,
pub dst_cid: Option<Bytes>,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct ConnectionClosed {
pub owner: Option<TransportOwner>,
pub connection_code: Option<ConnectionErrorCode>,
pub application_code: Option<ApplicationErrorCode>,
pub internal_code: Option<u32>,
pub reason: Option<String>,
pub trigger: Option<ConnectionClosedTrigger>,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct ConnectionIdUpdated {
pub owner: Option<TransportOwner>,
pub old: Option<Bytes>,
pub new: Option<Bytes>,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct SpinBitUpdated {
pub state: bool,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct ConnectionStateUpdated {
pub old: Option<ConnectionState>,
pub new: ConnectionState,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct MtuUpdated {
pub old: Option<u16>,
pub new: u16,
pub done: Option<bool>,
}