pub struct TagBudget {
pub name: &'static str,
pub soft_limit: usize,
pub hard_limit: usize,
pub current_usage: usize,
pub peak_usage: usize,
pub allocation_count: u64,
pub deallocation_count: u64,
}Expand description
Budget configuration and current usage for a specific tag.
Fields§
§name: &'static strTag name
soft_limit: usizeSoft limit (warning threshold)
hard_limit: usizeHard limit (allocation may fail)
current_usage: usizeCurrent usage in bytes
peak_usage: usizePeak usage (high water mark)
allocation_count: u64Number of allocations
deallocation_count: u64Number of deallocations
Implementations§
Source§impl TagBudget
impl TagBudget
Sourcepub fn new(name: &'static str, soft_limit: usize, hard_limit: usize) -> Self
pub fn new(name: &'static str, soft_limit: usize, hard_limit: usize) -> Self
Create a new tag budget.
Sourcepub fn check_status(&self, additional_size: usize) -> BudgetStatus
pub fn check_status(&self, additional_size: usize) -> BudgetStatus
Check the budget status for a potential allocation.
Sourcepub fn usage_percent(&self) -> f64
pub fn usage_percent(&self) -> f64
Calculate usage as a percentage of hard limit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TagBudget
impl RefUnwindSafe for TagBudget
impl Send for TagBudget
impl Sync for TagBudget
impl Unpin for TagBudget
impl UnwindSafe for TagBudget
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