Trait canadensis_core::session::SessionTracker
source · pub trait SessionTracker<I, N, T, D>where
I: Instant,{
// Required methods
fn get(&self, node: N) -> Option<&Session<I, T, D>>;
fn get_mut(&mut self, node: N) -> Option<&mut Session<I, T, D>>;
fn get_mut_or_insert_with<F>(
&mut self,
node: N,
generator: F
) -> Result<&mut Session<I, T, D>, OutOfMemoryError>
where N: Clone,
F: FnOnce() -> Session<I, T, D>;
fn insert(
&mut self,
node: N,
session: Session<I, T, D>
) -> Result<(), OutOfMemoryError>;
fn remove(&mut self, node: N);
fn remove_expired(&mut self, now: I);
}
Expand description
Something that can keep track of receive sessions associated with other nodes
This is some kind of map from node ID to session.
Type parameters:
I
: A time instantN
: A node IDT
: A transfer IDD
: Additional transport-specific session data
Required Methods§
sourcefn get(&self, node: N) -> Option<&Session<I, T, D>>
fn get(&self, node: N) -> Option<&Session<I, T, D>>
Returns a reference to the session for the provided node, if one exists
sourcefn get_mut(&mut self, node: N) -> Option<&mut Session<I, T, D>>
fn get_mut(&mut self, node: N) -> Option<&mut Session<I, T, D>>
Returns a mutable reference to the session for the provided node, if one exists
sourcefn get_mut_or_insert_with<F>(
&mut self,
node: N,
generator: F
) -> Result<&mut Session<I, T, D>, OutOfMemoryError>where
N: Clone,
F: FnOnce() -> Session<I, T, D>,
fn get_mut_or_insert_with<F>( &mut self, node: N, generator: F ) -> Result<&mut Session<I, T, D>, OutOfMemoryError>where N: Clone, F: FnOnce() -> Session<I, T, D>,
Returns a mutable reference to the session for the provided node
If no session exists, this function calls the provided function, inserts the result, and returns a mutable reference to it.
sourcefn insert(
&mut self,
node: N,
session: Session<I, T, D>
) -> Result<(), OutOfMemoryError>
fn insert( &mut self, node: N, session: Session<I, T, D> ) -> Result<(), OutOfMemoryError>
Inserts a session
If another session with the same node already exists, it is removed.
sourcefn remove(&mut self, node: N)
fn remove(&mut self, node: N)
Removes a session for the provided node if one exists
If no matching session exists, this function has no effect.
sourcefn remove_expired(&mut self, now: I)
fn remove_expired(&mut self, now: I)
Removes all sessions that have expired