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§
Required Methods§
Sourcefn with_fixed_capacity(_: usize) -> Result<Slabber, Self::Error>
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.
Sourcefn reserve_next(&mut self) -> Result<ReservedSlot, Self::Error>
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
Sourcefn take_reserved_with(
&mut self,
_: ReservedSlot,
_: T,
) -> Result<usize, Self::Error>
fn take_reserved_with( &mut self, _: ReservedSlot, _: T, ) -> Result<usize, Self::Error>
Take the previously reserved slot
Sourcefn take_next_with(&mut self, _: T) -> Result<usize, Self::Error>
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
Sourcefn mark_for_reuse(&mut self, _: usize) -> Result<T, Self::Error>
fn mark_for_reuse(&mut self, _: usize) -> Result<T, Self::Error>
Mark a given slot for re-use
Sourcefn slot_get_mut(&mut self, _: usize) -> Result<Option<&mut T>, Self::Error>
fn slot_get_mut(&mut self, _: usize) -> Result<Option<&mut T>, Self::Error>
Get mutable reference of slot
Sourcefn reap(&mut self) -> Option<usize>
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.