pub trait BitAlloc: Default {
const CAP: usize;
const DEFAULT: Self;
// Required methods
fn alloc(&mut self) -> Option<usize>;
fn alloc_contiguous(
&mut self,
base: Option<usize>,
size: usize,
align_log2: usize,
) -> Option<usize>;
fn next(&self, key: usize) -> Option<usize>;
fn dealloc(&mut self, key: usize) -> bool;
fn dealloc_contiguous(&mut self, base: usize, size: usize) -> bool;
fn insert(&mut self, range: Range<usize>);
fn remove(&mut self, range: Range<usize>);
fn any(&self) -> bool;
fn is_empty(&self) -> bool;
fn test(&self, key: usize) -> bool;
}
Expand description
Allocator of a bitmap, able to allocate / free bits.
Required Associated Constants§
Required Methods§
Sourcefn alloc_contiguous(
&mut self,
base: Option<usize>,
size: usize,
align_log2: usize,
) -> Option<usize>
fn alloc_contiguous( &mut self, base: Option<usize>, size: usize, align_log2: usize, ) -> Option<usize>
Allocate a free block with a given size, and return the first bit position.
If base
is not None
, the allocator will try to allocate the block at the given base.
Sourcefn next(&self, key: usize) -> Option<usize>
fn next(&self, key: usize) -> Option<usize>
Find a index not less than a given key, where the bit is free.
Sourcefn dealloc(&mut self, key: usize) -> bool
fn dealloc(&mut self, key: usize) -> bool
Free an allocated bit.
Returns true if successful, false if the bit is already free.
Sourcefn dealloc_contiguous(&mut self, base: usize, size: usize) -> bool
fn dealloc_contiguous(&mut self, base: usize, size: usize) -> bool
Free a contiguous block of bits.
Returns true if successful, false if the bits in the range are already free.
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.