Slabbable

Trait Slabbable 

Source
pub trait Slabbable<Slabber, T> {
    type Error;

    // Required methods
    fn with_fixed_capacity(_: usize) -> Result<Slabber, Self::Error>;
    fn reserve_next(&mut self) -> Result<ReservedSlot, Self::Error>;
    fn take_reserved_with(
        &mut self,
        _: ReservedSlot,
        _: T,
    ) -> Result<usize, Self::Error>;
    fn take_next_with(&mut self, _: T) -> Result<usize, Self::Error>;
    fn mark_for_reuse(&mut self, _: usize) -> Result<T, Self::Error>;
    fn slot_get_mut(&mut self, _: usize) -> Result<Option<&mut T>, Self::Error>;
    fn slot_get_ref(&self, _: usize) -> Result<Option<&T>, Self::Error>;
    fn capacity(&self) -> usize;
    fn remaining(&self) -> Option<usize>;
    fn reap(&mut self) -> Option<usize>;
}
Expand description

See module documentation of guarantees needed.

Required Associated Types§

Source

type Error

Error

Required Methods§

Source

fn with_fixed_capacity(_: usize) -> Result<Slabber, Self::Error>

Provided with capacity the impl must keep the underlying T addresses stable. The capacity must be fixed and must not change.

Source

fn reserve_next(&mut self) -> Result<ReservedSlot, Self::Error>

Reserve the next free slot, ideally with least re-used ID and return it’s key ID

Source

fn take_reserved_with( &mut self, _: ReservedSlot, _: T, ) -> Result<usize, Self::Error>

Take the previously reserved slot

Source

fn take_next_with(&mut self, _: T) -> Result<usize, Self::Error>

Take the next free slot, ideally with least re-used ID and return it’s key ID

Source

fn mark_for_reuse(&mut self, _: usize) -> Result<T, Self::Error>

Mark a given slot for re-use

Source

fn slot_get_mut(&mut self, _: usize) -> Result<Option<&mut T>, Self::Error>

Get mutable reference of slot

Source

fn slot_get_ref(&self, _: usize) -> Result<Option<&T>, Self::Error>

Get reference of slot

Source

fn capacity(&self) -> usize

The capacity of the slab-slotmap

Source

fn remaining(&self) -> Option<usize>

Remaining capacity of teh slab-slotmap

Source

fn reap(&mut self) -> Option<usize>

Reap memory that can be freed opportunistically-optionally but keep the capacity intanct. This may mean wiping out entries at the tail and re-allocating at the end etc. Implementations that don’t provide this should return None and the ones providing it must return the number of slots affected denoting the expected effetiveness of it. This is an opportunity to reap the freelist or gc in the periods that may afford slowness traded for opportunity to free up operating memory.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§