pub struct MemoryTracker { /* private fields */ }Expand description
A simple memory usage tracker that can be queried during parsing.
This helps embedded systems monitor and limit memory consumption. Note: This tracks allocations made through the tracker, not global heap usage.
Implementations§
Source§impl MemoryTracker
impl MemoryTracker
Sourcepub fn with_limit(limit: usize) -> Self
pub fn with_limit(limit: usize) -> Self
Creates a new memory tracker with a specified byte limit.
Sourcepub fn allocate(&self, bytes: usize) -> Result<(), &'static str>
pub fn allocate(&self, bytes: usize) -> Result<(), &'static str>
Records an allocation. Returns Err if it would exceed the limit.
Sourcepub fn deallocate(&self, bytes: usize)
pub fn deallocate(&self, bytes: usize)
Records a deallocation.
Trait Implementations§
Source§impl Debug for MemoryTracker
impl Debug for MemoryTracker
Auto Trait Implementations§
impl !Freeze for MemoryTracker
impl !RefUnwindSafe for MemoryTracker
impl !Sync for MemoryTracker
impl Send for MemoryTracker
impl Unpin for MemoryTracker
impl UnsafeUnpin for MemoryTracker
impl UnwindSafe for MemoryTracker
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