Skip to main content

BufferAllocator

Trait BufferAllocator 

pub trait BufferAllocator {
    // Required methods
    fn allocate(len: u32) -> NonNull<MaybeUninit<u8>>;
    unsafe fn deallocate(ptr: NonNull<MaybeUninit<u8>>, len: u32);
}
Expand description

Trait used to allocate buffers for compio-driver’s buffer pool.

Default implementation is BoxAllocator, which uses Box to allocate and deallocate each buffer.

Required Methods§

fn allocate(len: u32) -> NonNull<MaybeUninit<u8>>

Allocate a chunk of memory with len.

unsafe fn deallocate(ptr: NonNull<MaybeUninit<u8>>, len: u32)

Deallocate a chunk of memory.

§Safety

The pointer passed in must be previously allocated by this allocator.

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§