pub struct SessionManager { /* private fields */ }Expand description
Session manager
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(config: SessionConfig) -> Self
pub fn new(config: SessionConfig) -> Self
Create a new session manager
Sourcepub fn create_session(&self, peer_id: PeerId) -> bool
pub fn create_session(&self, peer_id: PeerId) -> bool
Create a new session
Sourcepub fn get_session(&self, peer_id: &PeerId) -> Option<Session>
pub fn get_session(&self, peer_id: &PeerId) -> Option<Session>
Get a session
Sourcepub fn activate_session(&self, peer_id: &PeerId)
pub fn activate_session(&self, peer_id: &PeerId)
Mark session as active
Sourcepub fn mark_activity(&self, peer_id: &PeerId)
pub fn mark_activity(&self, peer_id: &PeerId)
Mark activity on a session
Sourcepub fn update_bandwidth(&self, peer_id: &PeerId, sent: u64, received: u64)
pub fn update_bandwidth(&self, peer_id: &PeerId, sent: u64, received: u64)
Update session bandwidth
Sourcepub fn record_message(&self, peer_id: &PeerId, sent: bool)
pub fn record_message(&self, peer_id: &PeerId, sent: bool)
Record message activity
Sourcepub fn update_metadata(&self, peer_id: &PeerId, metadata: SessionMetadata)
pub fn update_metadata(&self, peer_id: &PeerId, metadata: SessionMetadata)
Update session metadata
Sourcepub fn close_session(&self, peer_id: &PeerId)
pub fn close_session(&self, peer_id: &PeerId)
Close a session
Sourcepub fn remove_session(&self, peer_id: &PeerId) -> Option<Session>
pub fn remove_session(&self, peer_id: &PeerId) -> Option<Session>
Remove a closed session
Sourcepub fn get_all_sessions(&self) -> Vec<Session>
pub fn get_all_sessions(&self) -> Vec<Session>
Get all sessions
Sourcepub fn get_sessions_by_state(&self, state: SessionState) -> Vec<Session>
pub fn get_sessions_by_state(&self, state: SessionState) -> Vec<Session>
Get sessions by state
Sourcepub fn check_idle_sessions(&self) -> Vec<PeerId>
pub fn check_idle_sessions(&self) -> Vec<PeerId>
Check for idle sessions and mark them
Sourcepub fn cleanup_closed_sessions(&self) -> usize
pub fn cleanup_closed_sessions(&self) -> usize
Cleanup closed sessions
Sourcepub fn stats(&self) -> SessionStats
pub fn stats(&self) -> SessionStats
Get statistics
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Get session count
Sourcepub fn active_session_count(&self) -> usize
pub fn active_session_count(&self) -> usize
Get active session count
Auto Trait Implementations§
impl Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl !UnwindSafe for SessionManager
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> 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