pub struct ClientInfo {
pub id: Uuid,
pub subscription: Option<Subscription>,
pub last_seen: SystemTime,
pub sender: Sender<Message>,
pub auth_context: Option<AuthContext>,
pub remote_addr: SocketAddr,
/* private fields */
}Expand description
Information about a connected client
Fields§
§id: Uuid§subscription: Option<Subscription>§last_seen: SystemTime§sender: Sender<Message>§auth_context: Option<AuthContext>Authentication context for this client
remote_addr: SocketAddrClient’s IP address for rate limiting
Implementations§
Source§impl ClientInfo
impl ClientInfo
pub fn new( id: Uuid, sender: Sender<Message>, auth_context: Option<AuthContext>, remote_addr: SocketAddr, ) -> Self
Sourcepub fn record_egress(&self, bytes: usize) -> Option<u64>
pub fn record_egress(&self, bytes: usize) -> Option<u64>
Record bytes sent, returning true if within limit
Sourcepub fn record_inbound_message(&self) -> Option<u32>
pub fn record_inbound_message(&self) -> Option<u32>
Record an inbound client message, returning true if within limit.
pub fn update_last_seen(&mut self)
pub fn is_stale(&self, timeout: Duration) -> bool
pub async fn add_subscription( &self, sub_key: String, token: CancellationToken, ) -> bool
pub async fn remove_subscription(&self, sub_key: &str) -> bool
pub async fn cancel_all_subscriptions(&self)
pub async fn subscription_count(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ClientInfo
impl !RefUnwindSafe for ClientInfo
impl Send for ClientInfo
impl Sync for ClientInfo
impl Unpin for ClientInfo
impl UnsafeUnpin for ClientInfo
impl !UnwindSafe for ClientInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more