pub struct SessionSlab<T> { /* private fields */ }Expand description
Generational slab of sessions.
Implementations§
Source§impl<T> SessionSlab<T>
impl<T> SessionSlab<T>
Sourcepub fn new(capacity: usize) -> Result<Self, SlabError>
pub fn new(capacity: usize) -> Result<Self, SlabError>
Pre-allocates capacity slots (no T constructed yet).
§Errors
SlabError::Capacity when capacity is 0 or exceeds MAX_SLOTS.
Sourcepub fn insert(&mut self, value: T) -> Result<(u32, u16), SlabError>
pub fn insert(&mut self, value: T) -> Result<(u32, u16), SlabError>
Inserts a value, returning (slot, generation).
§Errors
SlabError::Exhausted when every slot is live.
Sourcepub fn remove(&mut self, slot: u32) -> Option<T>
pub fn remove(&mut self, slot: u32) -> Option<T>
Removes a value. The slot’s generation increments immediately so any in-flight token for the old generation becomes stale on reuse.
Sourcepub fn generation(&self, slot: u32) -> u16
pub fn generation(&self, slot: u32) -> u16
Generation currently assigned to a slot.
Trait Implementations§
Source§impl<T> GenerationBump<T> for SessionSlab<T>
impl<T> GenerationBump<T> for SessionSlab<T>
Source§fn bump_generation(&mut self, slot: u32)
fn bump_generation(&mut self, slot: u32)
Increments the slot generation, invalidating stale tokens.
Auto Trait Implementations§
impl<T> Freeze for SessionSlab<T>
impl<T> RefUnwindSafe for SessionSlab<T>where
Box<[Entry<T>]>: RefUnwindSafe,
impl<T> Send for SessionSlab<T>
impl<T> Sync for SessionSlab<T>
impl<T> Unpin for SessionSlab<T>
impl<T> UnsafeUnpin for SessionSlab<T>where
Box<[Entry<T>]>: UnsafeUnpin,
impl<T> UnwindSafe for SessionSlab<T>where
Box<[Entry<T>]>: UnwindSafe,
Blanket Implementations§
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