heapless::pool::boxed

Trait BoxPool

Source
pub trait BoxPool: Sized {
    type Data: 'static;

    // Provided methods
    fn alloc(value: Self::Data) -> Result<Box<Self>, Self::Data> { ... }
    fn manage(block: &'static mut BoxBlock<Self::Data>) { ... }
}
Expand description

A singleton that manages pool::boxed::Box-es

§Usage

Do not implement this trait yourself; instead use the box_pool! macro to create a type that implements this trait.

§Semver guarantees

Implementing this trait is exempt from semver guarantees. i.e. a new patch release is allowed to break downstream BoxPool implementations.

Using the trait, e.g. in generic code, does fall under semver guarantees.

Required Associated Types§

Source

type Data: 'static

The data type managed by the memory pool

Provided Methods§

Source

fn alloc(value: Self::Data) -> Result<Box<Self>, Self::Data>

Allocate a new Box initialized to the given value

manage should be called at least once before calling alloc

§Errors

The Error variant is returned when the memory pool has run out of memory blocks

Source

fn manage(block: &'static mut BoxBlock<Self::Data>)

Add a statically allocated memory block to the memory pool

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§