Skip to main content

DynamicBudgetKey

Struct DynamicBudgetKey 

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

One registered dynamic key under a budget tree.

Cloning shares the same registration and generation. Every clone observes the same closed state, and only the last generation that holds a name can release it.

Implementations§

Source§

impl DynamicBudgetKey

Source

pub fn name(&self) -> &str

Returns the name this key holds.

Source

pub fn generation(&self) -> u64

Returns the unique generation of this registration.

Source

pub fn budget(&self) -> ResourceBudget

Returns the budget this key owns.

The key is the admission boundary for a dynamic key: work that has to be waited for by Self::retire_until must be admitted through Self::try_acquire or against this budget, because retirement waits for the reservations on this node.

Source

pub fn is_closed(&self) -> bool

Returns whether admission is closed for this key.

Source

pub fn close(&self)

Closes admission for this key without waiting for its work.

Source

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

Acquires capacity from this key.

§Errors

Returns DynamicKeyAdmissionRejection::Closed once the key is retiring, or the budget rejection when the key’s budget is full.

Source

pub async fn retire_until(&self, deadline: Instant) -> DynamicKeyRetirement

Closes admission and waits for the reservations on this key to drain.

Retirement completes only when the node holds no reservations, which is what makes it safe for the caller to stop accounting for this key. When deadline elapses first, the registration stays held and the returned DynamicKeyRetirement reports the real remaining work.

Trait Implementations§

Source§

impl Clone for DynamicBudgetKey

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 DynamicBudgetKey

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