pub struct CallbackMemory<FReserve>{ /* private fields */ }Expand description
Implements MemoryShared by delegating to a closure.
This can be used to construct wrapping memory providers that add logic or configuration on top of an existing memory provider.
Implementations§
Source§impl<FReserve> CallbackMemory<FReserve>
impl<FReserve> CallbackMemory<FReserve>
Sourcepub fn new(reserve_fn: FReserve) -> Self
pub fn new(reserve_fn: FReserve) -> Self
Creates a new instance implemented via the provided callback.
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<FReserve> Clone for CallbackMemory<FReserve>
impl<FReserve> Clone for CallbackMemory<FReserve>
Source§impl<FReserve> Debug for CallbackMemory<FReserve>
impl<FReserve> Debug for CallbackMemory<FReserve>
Auto Trait Implementations§
impl<FReserve> Freeze for CallbackMemory<FReserve>
impl<FReserve> RefUnwindSafe for CallbackMemory<FReserve>where
FReserve: RefUnwindSafe,
impl<FReserve> Send for CallbackMemory<FReserve>
impl<FReserve> Sync for CallbackMemory<FReserve>
impl<FReserve> Unpin for CallbackMemory<FReserve>
impl<FReserve> UnwindSafe for CallbackMemory<FReserve>where
FReserve: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more