Skip to main content

BufferProvider

Trait BufferProvider 

Source
pub trait BufferProvider {
    // Required methods
    fn alloc(&self, len: usize) -> Result<Allocation, AllocError>;
    fn dealloc(&self, addr: u64) -> Result<(), AllocError>;

    // Provided methods
    fn max_alloc_len(&self) -> usize { ... }
    fn reset(&self) { ... }
    fn alloc_sg(
        &self,
        total_len: usize,
    ) -> Result<SmallVec<[Allocation; 4]>, AllocError> { ... }
}
Expand description

Trait for buffer providers.

Required Methods§

Source

fn alloc(&self, len: usize) -> Result<Allocation, AllocError>

Allocate one buffer that can hold at least len bytes.

Source

fn dealloc(&self, addr: u64) -> Result<(), AllocError>

Free a previously allocated segment by start address.

Provided Methods§

Source

fn max_alloc_len(&self) -> usize

Preferred maximum size of one allocation segment.

Source

fn reset(&self)

Reset the pool to initial state.

Source

fn alloc_sg( &self, total_len: usize, ) -> Result<SmallVec<[Allocation; 4]>, AllocError>

Allocate scatter/gather segments for a logical payload of total_len bytes.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: BufferProvider> BufferProvider for Arc<T>

Source§

impl<T: BufferProvider> BufferProvider for Rc<T>

Implementors§