pub struct TurnBudget { /* private fields */ }Expand description
One turn’s budget, measured against the clock it started on.
Implementations§
Source§impl TurnBudget
impl TurnBudget
Sourcepub const fn new(budget: ResourceBudget, started_at: DateTime<Utc>) -> Self
pub const fn new(budget: ResourceBudget, started_at: DateTime<Utc>) -> Self
Binds budget to the instant the turn was accepted.
Sourcepub const fn budget(&self) -> &ResourceBudget
pub const fn budget(&self) -> &ResourceBudget
The budget in force.
Sourcepub const fn started_at(&self) -> DateTime<Utc>
pub const fn started_at(&self) -> DateTime<Utc>
When the turn started.
Sourcepub fn exhausted(
&self,
spent: BudgetSpend,
now: DateTime<Utc>,
) -> Option<BudgetLimit>
pub fn exhausted( &self, spent: BudgetSpend, now: DateTime<Utc>, ) -> Option<BudgetLimit>
The first bound that is exhausted at now, if any.
The order is fixed — calls, then tokens, then the clock — so the same turn always reports the same bound, and a replay of it says the same thing.
Trait Implementations§
Source§impl Clone for TurnBudget
impl Clone for TurnBudget
impl Copy for TurnBudget
Source§impl Debug for TurnBudget
impl Debug for TurnBudget
impl Eq for TurnBudget
Source§impl PartialEq for TurnBudget
impl PartialEq for TurnBudget
impl StructuralPartialEq for TurnBudget
Auto Trait Implementations§
impl Freeze for TurnBudget
impl RefUnwindSafe for TurnBudget
impl Send for TurnBudget
impl Sync for TurnBudget
impl Unpin for TurnBudget
impl UnsafeUnpin for TurnBudget
impl UnwindSafe for TurnBudget
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.