Trait mz_ore::id_gen::IdAllocatorInner

source ·
pub trait IdAllocatorInner: Debug + Send {
    const NAME: &'static str;

    // Required methods
    fn new(min: u32, max: u32, mask: u32) -> Self;
    fn alloc(&mut self) -> Option<u32>;
    fn remove(&mut self, id: u32);
Expand description

Common trait for id allocators.

Required Associated Constants§


const NAME: &'static str

Name of the allocator.

Required Methods§


fn new(min: u32, max: u32, mask: u32) -> Self

Construct an allocator with the given range. Returned ids will be OR’d with mask. mask must not have any bits that could be set by a number <= max.


fn alloc(&mut self) -> Option<u32>

Allocate a new id.


fn remove(&mut self, id: u32)

Deallocate a used id, making it available for reuse.

Object Safety§

This trait is not object safe.