pub struct Heap { /* private fields */ }Expand description
Asynchronous file-backed heap allocator.
Manages variable-sized memory blocks within a file.
Implementations§
Source§impl Heap
impl Heap
Sourcepub async fn new(path: impl AsRef<Path>) -> TokioResult<Self>
pub async fn new(path: impl AsRef<Path>) -> TokioResult<Self>
Opens or creates a heap file at the given path.
Sourcepub async fn size(&self) -> TokioResult<usize>
pub async fn size(&self) -> TokioResult<usize>
Returns the current size of the heap file in bytes.
Sourcepub async fn alloc(&self, size: u64) -> TokioResult<HeapItem>
pub async fn alloc(&self, size: u64) -> TokioResult<HeapItem>
Allocates a new memory block of the given size.
Sourcepub async fn realloc(&self, item: &mut HeapItem, size: u64) -> TokioResult<bool>
pub async fn realloc(&self, item: &mut HeapItem, size: u64) -> TokioResult<bool>
Resizes the memory block. Reallocates if the new size exceeds the
block’s capacity. It returns true if reallocation happened else
false.
Auto Trait Implementations§
impl !Freeze for Heap
impl !RefUnwindSafe for Heap
impl Send for Heap
impl Sync for Heap
impl Unpin for Heap
impl UnsafeUnpin for Heap
impl !UnwindSafe for Heap
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