Skip to main content

SessionTable

Struct SessionTable 

Source
pub struct SessionTable<C: Config, const N: usize = 16> { /* private fields */ }
Available on crate feature rustcrypto only.
Expand description

The fixed-capacity set of established sessions.

Implementations§

Source§

impl<C: Config, const N: usize> SessionTable<C, N>

Source

pub const CHECK: ()

Compile-time proof that this table can keep §4.14.2.8’s promise.

A node SHALL support at least 3 CASE session contexts per fabric.

Referenced by SessionTable::new, so a table too small for the node’s Config fails the build at the first place one is constructed.

Source

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.

Source

pub fn len(&self) -> usize

How many sessions are established.

Source

pub fn is_empty(&self) -> bool

Whether none are.

Source

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.

Source

pub fn insert(&mut self, session: SecureSession) -> Result<()>

Installs a session.

Source

pub fn find(&self, local_session_id: SessionId) -> Option<&SecureSession>

The session a message addressed to local_session_id belongs to.

Source

pub fn find_mut( &mut self, local_session_id: SessionId, ) -> Option<&mut SecureSession>

The session, mutably.

Source

pub fn remove(&mut self, local_session_id: SessionId) -> bool

Removes a session, returning whether one was there.

Source

pub fn remove_fabric(&mut self, fabric: FabricIndex) -> usize

Removes every session on a fabric — what RemoveFabric does.

Source

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.

Source

pub fn iter(&self) -> impl Iterator<Item = &SecureSession>

Every session.

Trait Implementations§

Source§

impl<C: Config, const N: usize> Capacity for SessionTable<C, N>

Source§

const PER_FABRIC: usize

§11.1.4.4’s CaseSessionsPerFabric: the sessions this table guarantees each fabric.

The whole table divided among the fabrics, with no rounding up. §4.14.2.8 sets the floor at three and SessionTable::CHECK refuses a smaller table at compile time, so this never has to be clamped — and clamping is what would turn a table that is too small into an attribute that lies about it.

Source§

const TOTAL: usize = N

Total slots, across every fabric.
Source§

impl<C: Debug + Config, const N: usize> Debug for SessionTable<C, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C, const N: usize> Forget for SessionTable<C, N>

§

impl<C, const N: usize> Freeze for SessionTable<C, N>

§

impl<C, const N: usize> Move for SessionTable<C, N>

§

impl<C, const N: usize> RefUnwindSafe for SessionTable<C, N>

§

impl<C, const N: usize> Send for SessionTable<C, N>

§

impl<C, const N: usize> Sync for SessionTable<C, N>

§

impl<C, const N: usize> Unpin for SessionTable<C, N>

§

impl<C, const N: usize> UnsafeUnpin for SessionTable<C, N>

§

impl<C, const N: usize> UnwindSafe for SessionTable<C, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.