use std::time::Duration;
#[derive(Debug, Clone)]
#[non_exhaustive] pub enum SocketEvent {
Listening { endpoint: String },
BindFailed { endpoint: String, error_msg: String },
Accepted { endpoint: String, peer_addr: String },
AcceptFailed { endpoint: String, error_msg: String },
Connected { endpoint: String, peer_addr: String },
ConnectDelayed { endpoint: String, error_msg: String },
ConnectRetried {
endpoint: String,
interval: Duration,
},
ConnectFailed { endpoint: String, error_msg: String },
Closed { endpoint: String },
Disconnected { endpoint: String },
HandshakeFailed { endpoint: String, error_msg: String },
HandshakeSucceeded { endpoint: String },
ConnectionCongested { endpoint: String },
ConnectionUncongested { endpoint: String },
}
pub(crate) fn clean_endpoint_uri(uri: &str) -> &str {
match uri.find('#') {
Some(pos) => &uri[..pos],
None => uri,
}
}
pub type MonitorSender = fibre::mpsc::BoundedAsyncSender<SocketEvent>;
pub type MonitorReceiver = fibre::mpsc::BoundedAsyncReceiver<SocketEvent>;
pub const DEFAULT_MONITOR_CAPACITY: usize = 100;