pub struct Heap { /* private fields */ }Expand description
Heap manager for tracking memory allocations.
Implementations§
Source§impl Heap
impl Heap
Sourcepub fn new(config: HeapConfig) -> Self
pub fn new(config: HeapConfig) -> Self
Create a new heap with the given configuration.
Sourcepub fn allocate(&mut self, bytes: usize) -> Result<(), JErrorType>
pub fn allocate(&mut self, bytes: usize) -> Result<(), JErrorType>
Allocate memory on the heap.
Returns an error if the allocation would exceed the memory limit.
Sourcepub fn deallocate(&mut self, bytes: usize)
pub fn deallocate(&mut self, bytes: usize)
Deallocate memory from the heap.
Sourcepub fn get_allocated(&self) -> usize
pub fn get_allocated(&self) -> usize
Get the current allocated bytes.
Sourcepub fn get_max_bytes(&self) -> Option<usize>
pub fn get_max_bytes(&self) -> Option<usize>
Get the maximum allowed bytes, if any.
Sourcepub fn can_allocate(&self, bytes: usize) -> bool
pub fn can_allocate(&self, bytes: usize) -> bool
Check if allocation of the given size would succeed.
Sourcepub fn available_bytes(&self) -> Option<usize>
pub fn available_bytes(&self) -> Option<usize>
Get the remaining available bytes, if limited.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Heap
impl RefUnwindSafe for Heap
impl Send for Heap
impl Sync for Heap
impl Unpin 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