pub struct FixedBlockTestMemory { /* private fields */ }Expand description
A memory provider that cuts the memory allocation into blocks of fixed size and delegates to the Rust global allocator for allocating those blocks.
This is meant for test scenarios where a specific memory block size is important.
This memory provider is a simple implementation that does not perform any pooling or performance optimization, so should not be used in real code.
Implementations§
Source§impl FixedBlockTestMemory
impl FixedBlockTestMemory
Sourcepub fn new(block_size: NonZero<BlockSize>) -> Self
pub fn new(block_size: NonZero<BlockSize>) -> Self
Creates a new instance of the memory provider.
Sourcepub fn reserve(&self, min_bytes: usize) -> BytesBuf
pub fn reserve(&self, min_bytes: usize) -> BytesBuf
Reserves at least min_bytes bytes of memory capacity.
Returns an empty BytesBuf that can be used to fill the reserved memory with data.
The memory provider may provide more memory than requested.
The memory reservation request will always be fulfilled, obtaining more memory from the operating system if necessary.
§Zero-sized reservations
Reserving zero bytes of memory is a valid operation and will return a BytesBuf
with zero or more bytes of capacity.
§Panics
May panic if the operating system runs out of memory.
Trait Implementations§
Source§impl Clone for FixedBlockTestMemory
impl Clone for FixedBlockTestMemory
Source§fn clone(&self) -> FixedBlockTestMemory
fn clone(&self) -> FixedBlockTestMemory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more