pub unsafe trait SlabStore {
type Item;
// Required methods
fn alloc(&self, value: Self::Item) -> Slot<Self::Item>;
fn free(&self, slot: Slot<Self::Item>);
fn take(&self, slot: Slot<Self::Item>) -> Self::Item;
}Expand description
Base trait for slab storage — allocation, deallocation, and value extraction.
§Allocation
alloc always returns a valid slot:
- Unbounded slabs grow as needed — allocation never fails.
- Bounded slabs panic if capacity is exceeded. This is intentional: running out of pre-allocated capacity is a capacity planning error, equivalent to OOM. The system should crash loudly rather than silently drop work.
For fallible allocation on bounded slabs, use BoundedStore::try_alloc.
§Safety
Implementors must uphold:
freemust drop the value and return the slot to the freelist.takemust move the value out and return the slot to the freelist.- The slot must have been allocated from
self.