pub struct SessionTable<C: Config, const N: usize> { /* private fields */ }rustcrypto only.Expand description
The fixed-capacity set of established sessions.
Implementations§
Source§impl<C: Config, const N: usize> SessionTable<C, N>
impl<C: Config, const N: usize> SessionTable<C, N>
Sourcepub fn new(first_id: u16) -> Self
pub fn new(first_id: u16) -> Self
An empty table whose first session id is first_id.
§4.13.2.4 requires a fresh local session id that does not collide with a live one; starting from a random value rather than 1 keeps a node’s ids from being guessable across a reboot.
Sourcepub fn allocate_id(&mut self) -> Result<SessionId>
pub fn allocate_id(&mut self) -> Result<SessionId>
Allocates a local session id that no live session is using (§4.13.2.4).
Session id 0 is never returned: with a unicast session type it means the unsecured session, so handing it out would make a secure session indistinguishable from no session at all.
Sourcepub fn insert(&mut self, session: SecureSession) -> Result<()>
pub fn insert(&mut self, session: SecureSession) -> Result<()>
Installs a session.
Sourcepub fn find(&self, local_session_id: SessionId) -> Option<&SecureSession>
pub fn find(&self, local_session_id: SessionId) -> Option<&SecureSession>
The session a message addressed to local_session_id belongs to.
Sourcepub fn find_mut(
&mut self,
local_session_id: SessionId,
) -> Option<&mut SecureSession>
pub fn find_mut( &mut self, local_session_id: SessionId, ) -> Option<&mut SecureSession>
The session, mutably.
Sourcepub fn remove(&mut self, local_session_id: SessionId) -> bool
pub fn remove(&mut self, local_session_id: SessionId) -> bool
Removes a session, returning whether one was there.
Sourcepub fn remove_fabric(&mut self, fabric: FabricIndex) -> usize
pub fn remove_fabric(&mut self, fabric: FabricIndex) -> usize
Removes every session on a fabric — what RemoveFabric does.
Sourcepub fn least_recently_used(&self) -> Option<SessionId>
pub fn least_recently_used(&self) -> Option<SessionId>
The session that has gone unused longest, which is what §4.11.1.1 evicts when the table is full.
Sourcepub fn iter(&self) -> impl Iterator<Item = &SecureSession>
pub fn iter(&self) -> impl Iterator<Item = &SecureSession>
Every session.