mz_ore::id_gen

Trait 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.

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§