pub struct WorkBudget<'a> { /* private fields */ }Expand description
A sticky, context-free local work counter.
Implementations§
Source§impl WorkBudget<'static>
impl WorkBudget<'static>
Source§impl<'a> WorkBudget<'a>
impl<'a> WorkBudget<'a>
Sourcepub fn charge_by(&self, work: usize) -> bool
pub fn charge_by(&self, work: usize) -> bool
Charges several work units, with sticky exhaustion on refusal.
Sourcepub fn child_slice(&self, limit: usize) -> WorkBudget<'static>
pub fn child_slice(&self, limit: usize) -> WorkBudget<'static>
Creates an independent child slice capped by this budget’s remainder.
Sourcepub fn session_child_slice(&self, limit: usize) -> WorkBudget<'_>
pub fn session_child_slice(&self, limit: usize) -> WorkBudget<'_>
Creates a child slice capped by this budget’s remainder and attached to its session.
Sourcepub fn consume_child(&self, child: &WorkBudget<'_>) -> bool
pub fn consume_child(&self, child: &WorkBudget<'_>) -> bool
Charges this budget for work consumed by a child slice.
Sourcepub fn refuse(&self, operation: &'static str) -> CodecError
pub fn refuse(&self, operation: &'static str) -> CodecError
Classifies this local budget’s refusal as a resource limit.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !Freeze for WorkBudget<'a>
impl<'a> !RefUnwindSafe for WorkBudget<'a>
impl<'a> !Send for WorkBudget<'a>
impl<'a> !Sync for WorkBudget<'a>
impl<'a> !UnwindSafe for WorkBudget<'a>
impl<'a> Unpin for WorkBudget<'a>
impl<'a> UnsafeUnpin for WorkBudget<'a>
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