pub trait MemoryPool {
// Required methods
fn allocate(&self, size: usize, align: usize) -> Result<NonNull<u8>>;
unsafe fn deallocate(
&self,
ptr: NonNull<u8>,
size: usize,
align: usize,
) -> Result<()>;
fn capacity(&self) -> usize;
fn used(&self) -> usize;
unsafe fn reset(&self) -> Result<()>;
// Provided method
fn available(&self) -> usize { ... }
}Expand description
Memory pool trait for unified pool interface
Required Methods§
Sourcefn allocate(&self, size: usize, align: usize) -> Result<NonNull<u8>>
fn allocate(&self, size: usize, align: usize) -> Result<NonNull<u8>>
Allocate memory from the pool
§Errors
Returns PoolExhausted if no memory is available
Returns InvalidAlignment if alignment requirements cannot be met
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".