pub trait SlabAllocator<T> {
    // Required methods
    fn insert(&mut self, value: T) -> u32;
    fn remove(&mut self, key: u32) -> T;
    fn get(&self, key: u32) -> Option<&T>;
    fn get_mut(&mut self, key: u32) -> Option<&mut T>;
    fn clear(&mut self);
    fn len(&self) -> usize;

    // Provided methods
    fn reserve(&mut self, additional: usize) { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

A backend allocator for TimerDriverBase.

Required Methods§

source

fn insert(&mut self, value: T) -> u32

§Panics

Panics if the key is not found

source

fn remove(&mut self, key: u32) -> T

§Panics

Panics if the key is not found

source

fn get(&self, key: u32) -> Option<&T>

Get reference to the value by key.

source

fn get_mut(&mut self, key: u32) -> Option<&mut T>

Get mutable reference to the value by key.

source

fn clear(&mut self)

Clear all elements.

source

fn len(&self) -> usize

Get the number of elements.

Provided Methods§

source

fn reserve(&mut self, additional: usize)

Reserve extra space than len() for slab.

For unsupported slab implementations(e.g. for embedded slabs), this method just does nothing.

source

fn is_empty(&self) -> bool

Check if slab allocator is empty

Implementations on Foreign Types§

source§

impl<T> SlabAllocator<T> for Slab<T>

source§

fn insert(&mut self, value: T) -> u32

source§

fn remove(&mut self, key: u32) -> T

source§

fn get(&self, key: u32) -> Option<&T>

source§

fn get_mut(&mut self, key: u32) -> Option<&mut T>

source§

fn clear(&mut self)

source§

fn len(&self) -> usize

source§

fn reserve(&mut self, additional: usize)

Implementors§