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 instant
  • N: A node ID
  • T: A transfer ID
  • D: Additional transport-specific session data

Required Methods§

source

fn get(&self, node: N) -> Option<&Session<I, T, D>>

Returns a reference to the session for the provided node, if one exists

source

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

source

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.

source

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.

source

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.

source

fn remove_expired(&mut self, now: I)

Removes all sessions that have expired

Implementors§

source§

impl<I, N, T, D> SessionTracker<I, N, T, D> for SessionDynamicMap<I, N, T, D>where I: Instant, N: Ord + Clone + Debug,

source§

impl<I, N, T, D, const C: usize> SessionTracker<I, N, T, D> for SessionArray<I, T, D, C>where I: Instant, N: Into<usize>,

source§

impl<I, N, T, D, const C: usize> SessionTracker<I, N, T, D> for SessionLinearMap<I, N, T, D, C>where I: Instant, N: Eq + Clone,