Skip to main content

SlabItem

Trait SlabItem 

Source
pub trait SlabItem {
    type Key: Clone + PartialEq + Eq + Hash;
    type Layout: SlabItemLayout;

    // Required method
    fn label() -> Cow<'static, str>;
}
Expand description

Describes the type of the data that a SlabAllocator will store.

The actual type that you implement this trait on doesn’t matter; only the associated types Self::Key and Self::Layout do. Typically, you implement this trait on a unit struct.

See crate::mesh::allocator::MeshSlabItem for an example of usage.

Required Associated Types§

Source

type Key: Clone + PartialEq + Eq + Hash

The key that’s used to look up items in the allocator.

Source

type Layout: SlabItemLayout

A type that describes the layout of items within a single slab.

If this slab allocator only allocates items of a single type, this type can simply be a unit struct. However, if you wish to have a single slab allocator that manages slabs of differing types, you can store metadata within values of this type that describes the size and alignment requirements of the objects within the slab. Each slab that the slab allocator manages contains an instance of this value so that it can track size and alignment requirements for that slab.

Required Methods§

Source

fn label() -> Cow<'static, str>

Returns a suitable debugging label describing the type of elements that this slab item stores.

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§