pub struct Session {
pub peer_id: PeerId,
pub state: SessionState,
pub created_at: Instant,
pub last_activity: Instant,
pub closed_at: Option<Instant>,
pub bytes_sent: u64,
pub bytes_received: u64,
pub messages_sent: u64,
pub messages_received: u64,
pub metadata: SessionMetadata,
}Expand description
Connection session information
Fields§
§peer_id: PeerIdPeer ID
state: SessionStateSession state
created_at: InstantSession creation time
last_activity: InstantLast activity time
closed_at: Option<Instant>Session closed time (if closed)
bytes_sent: u64Bytes sent in this session
bytes_received: u64Bytes received in this session
messages_sent: u64Number of messages sent
messages_received: u64Number of messages received
metadata: SessionMetadataCustom session metadata
Implementations§
Source§impl Session
impl Session
Sourcepub fn idle_duration(&self) -> Duration
pub fn idle_duration(&self) -> Duration
Get time since last activity
Sourcepub fn mark_activity(&mut self)
pub fn mark_activity(&mut self)
Mark activity
Sourcepub fn add_bytes_sent(&mut self, bytes: u64)
pub fn add_bytes_sent(&mut self, bytes: u64)
Update sent bytes
Sourcepub fn add_bytes_received(&mut self, bytes: u64)
pub fn add_bytes_received(&mut self, bytes: u64)
Update received bytes
Sourcepub fn record_message_sent(&mut self)
pub fn record_message_sent(&mut self)
Record message sent
Sourcepub fn record_message_received(&mut self)
pub fn record_message_received(&mut self)
Record message received
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnwindSafe for Session
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more