pub struct AllocTracker { /* private fields */ }
Expand description
Allocation tracker with total memory limit.
Implementations§
Source§impl AllocTracker
impl AllocTracker
Sourcepub fn with_limit(bytes_left: usize) -> Self
pub fn with_limit(bytes_left: usize) -> Self
Creates a memory allocation tracker with allowed allocation limit.
Sourcepub fn alloc<T>(&self, count: usize) -> Result<AllocHandle, Error>
pub fn alloc<T>(&self, count: usize) -> Result<AllocHandle, Error>
Records an allocation of count
number of T
, and returns handle of the record.
Returns an error if the allocation exceeds the current limit.
Sourcepub fn expand_limit(&self, by_bytes: usize)
pub fn expand_limit(&self, by_bytes: usize)
Expands the current limit by by_bytes
bytes.
Trait Implementations§
Source§impl Clone for AllocTracker
impl Clone for AllocTracker
Source§fn clone(&self) -> AllocTracker
fn clone(&self) -> AllocTracker
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for AllocTracker
impl RefUnwindSafe for AllocTracker
impl Send for AllocTracker
impl Sync for AllocTracker
impl Unpin for AllocTracker
impl UnwindSafe for AllocTracker
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