pub struct MemoryManager { /* private fields */ }Expand description
A memory manager that tracks allocated memory using a bump allocator and ensures that memory is deallocated and dropped properly when the manager is dropped.
Implementations§
Source§impl MemoryManager
impl MemoryManager
Sourcepub fn new() -> MemoryManager
pub fn new() -> MemoryManager
Create a new memory manager.
Trait Implementations§
Source§impl Allocator for MemoryManager
impl Allocator for MemoryManager
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Attempts to allocate a block of memory. Read more
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Behaves like
allocate, but also ensures that the returned memory is zero-initialized. Read moreSource§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
Deallocates the memory referenced by
ptr. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Attempts to extend the memory block. Read more
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Behaves like
grow, but also ensures that the new contents are set to zero before being
returned. Read moreSource§impl Drop for MemoryManager
impl Drop for MemoryManager
Source§impl<'a> WriterFactory for MemoryManager
impl<'a> WriterFactory for MemoryManager
Source§fn new_reverse(
&self,
size: usize,
) -> Result<ReverseSliceWriter<'_>, EncodeError>
fn new_reverse( &self, size: usize, ) -> Result<ReverseSliceWriter<'_>, EncodeError>
Create a new reverse writer.
Auto Trait Implementations§
impl !Freeze for MemoryManager
impl !RefUnwindSafe for MemoryManager
impl !Send for MemoryManager
impl !Sync for MemoryManager
impl Unpin for MemoryManager
impl !UnwindSafe for MemoryManager
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