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§

source

const NAME: &'static str

Name of the allocator.

Required Methods§

source

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.

source

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

Allocate a new id.

source

fn remove(&mut self, id: u32)

Deallocate a used id, making it available for reuse.

Object Safety§

This trait is not object safe.

Implementors§