pub struct MemoryAccountant { /* private fields */ }Expand description
Budget enforcer for memory-constrained edge devices. All methods are &self — interior mutability via atomics.
Implementations§
Source§impl MemoryAccountant
impl MemoryAccountant
Sourcepub fn with_budget(bytes: usize) -> Self
pub fn with_budget(bytes: usize) -> Self
Set a byte ceiling. Allocations exceeding this fail.
Sourcepub fn try_allocate(&self, bytes: usize) -> Result<()>
pub fn try_allocate(&self, bytes: usize) -> Result<()>
Attempt to allocate bytes. CAS-based, no TOCTOU.
Sourcepub fn set_budget(&self, limit: Option<usize>) -> Result<()>
pub fn set_budget(&self, limit: Option<usize>) -> Result<()>
Runtime budget adjustment. None removes limit. Returns Err if new limit exceeds startup ceiling.
Sourcepub fn usage(&self) -> MemoryUsage
pub fn usage(&self) -> MemoryUsage
Snapshot of current memory state.
pub fn try_allocate_for( &self, bytes: usize, subsystem: &str, operation: &str, hint: &str, ) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MemoryAccountant
impl RefUnwindSafe for MemoryAccountant
impl Send for MemoryAccountant
impl Sync for MemoryAccountant
impl Unpin for MemoryAccountant
impl UnsafeUnpin for MemoryAccountant
impl UnwindSafe for MemoryAccountant
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