Trait bytes::alloc::Allocator [] [src]

pub trait Allocator: Sync + Send {
    fn allocate(&self, len: usize) -> MemRef;
    fn deallocate(&self, mem: *mut Mem);
}

Allocates memory to be used by Bufs or Bytes. Allows allocating memory using alternate stratgies than the default Rust heap allocator. Also does not require that allocations are continuous in memory.

For example, an alternate allocator could use a slab of 4kb chunks of memory and return as many chunks as needed to satisfy the length requirement.

Required Methods

fn allocate(&self, len: usize) -> MemRef

Allocate memory. May or may not be contiguous.

fn deallocate(&self, mem: *mut Mem)

Deallocate a chunk of memory

Implementors