Skip to main content

ResourceBudget

Struct ResourceBudget 

Source
pub struct ResourceBudget { /* private fields */ }
Expand description

Represents resource budget.

Implementations§

Source§

impl ResourceBudget

Source

pub fn child( &self, name: impl Into<String>, limit: BudgetLimit, ) -> Result<Self, RuntimeContractViolation>

Creates a child that inherits every dynamic ancestor’s admission state.

Creating a static child after closure is allowed; the resulting handle remains closed and cannot acquire or accept rebound permits.

§Errors

Returns a contract violation when the child name is blank or malformed, its limit is invalid, or its limit exceeds its parent.

Source

pub fn register_dynamic_child( &self, name: impl Into<String>, limit: BudgetLimit, ) -> Result<DynamicBudgetKey, DynamicKeyRegistrationFailure>

Registers a bounded dynamic child key under this budget.

The key owns a child budget and holds its name reserved until DynamicBudgetKey::retire_until observes that the child has no reservations left. A name that is already held cannot be registered again, so a retired generation never runs beside the one that replaced it. Use Self::child when the key does not need a retirement lifecycle.

§Errors

Returns DynamicKeyRegistrationFailure when the child contract is invalid, a dynamic ancestor has closed, the name is still held, or the tree holds its maximum number of dynamic keys.

Source

pub fn is_closed(&self) -> bool

Returns whether a dynamic ancestor has permanently closed admission. Existing permits remain valid and can still be released or moved to an open budget.

Source

pub fn try_acquire( &self, bytes: usize, class: BudgetClass, ) -> Result<ResourcePermit, BudgetRejection>

Attempts to acquire.

A BudgetRejection is a normal bounded outcome when the requested capacity is unavailable; it is not an operational runtime failure.

Source

pub fn try_acquire_data( &self, bytes: usize, ) -> Result<ResourcePermit, BudgetRejection>

Attempts to acquire data.

A BudgetRejection is a normal bounded outcome when data capacity is unavailable; it is not an operational runtime failure.

Source

pub fn try_acquire_control( &self, bytes: usize, ) -> Result<ResourcePermit, BudgetRejection>

Attempts to acquire control.

A BudgetRejection is a normal bounded outcome when control capacity is unavailable; it is not an operational runtime failure.

Source

pub fn snapshot(&self) -> BudgetSnapshot

Returns the snapshot.

Source

pub fn path(&self) -> &str

Returns the path.

Source

pub fn limit(&self) -> BudgetLimit

Returns the limit.

Source

pub fn monotonic_now(&self) -> Duration

Returns the current instant from this tree’s injected monotonic clock.

Source

pub fn record_dropped(&self, count: usize)

Records items discarded by a queue or custom retention boundary.

Source

pub fn record_coalesced(&self, count: usize)

Records items folded into an already retained logical item.

Source

pub fn record_slow_consumer_closed(&self)

Records a slow consumer closed by this budget’s full policy.

Trait Implementations§

Source§

impl Clone for ResourceBudget

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResourceBudget

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more