pub struct QuotaUsage {
pub requests_this_month: u64,
pub tokens_this_month: u64,
pub month_key: u32,
}Expand description
Per-mapping monthly quota consumption tracker.
Fields§
§requests_this_month: u64Number of requests this month.
tokens_this_month: u64Number of tokens consumed this month.
month_key: u32The month this counter is tracking (year * 12 + month).
Implementations§
Source§impl QuotaUsage
impl QuotaUsage
Sourcepub fn current_month_key() -> u32
pub fn current_month_key() -> u32
Returns the current month key (year * 12 + month, Jan = 1).
Sourcepub fn maybe_reset(&mut self)
pub fn maybe_reset(&mut self)
Resets if the month has changed.
Sourcepub fn record_usage(&mut self, tokens: u64)
pub fn record_usage(&mut self, tokens: u64)
Records a request with its token usage.
Sourcepub fn is_within_quota(&self, quota: Option<&Quota>) -> bool
pub fn is_within_quota(&self, quota: Option<&Quota>) -> bool
Checks whether quota has been exceeded.
Trait Implementations§
Source§impl Clone for QuotaUsage
impl Clone for QuotaUsage
Source§fn clone(&self) -> QuotaUsage
fn clone(&self) -> QuotaUsage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QuotaUsage
impl Debug for QuotaUsage
Auto Trait Implementations§
impl Freeze for QuotaUsage
impl RefUnwindSafe for QuotaUsage
impl Send for QuotaUsage
impl Sync for QuotaUsage
impl Unpin for QuotaUsage
impl UnsafeUnpin for QuotaUsage
impl UnwindSafe for QuotaUsage
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