Skip to main content

RateWindow

Struct RateWindow 

Source
pub struct RateWindow {
    pub used_percent: f64,
    pub raw_used_percent: Option<f64>,
    pub resets_at: Option<String>,
    pub window_minutes: Option<i64>,
    pub used_count: Option<f64>,
    pub total_count: Option<f64>,
    pub regeneration: Option<Regeneration>,
}
Expand description

One rate-limit window: how much of a quota pool is spent and when it resets.

Fields§

§used_percent: f64

0..100 percent of the window’s quota consumed. This is the EFFECTIVE number consumers pace on: when banked-reset relaxation applies it is zeroed, and the provider-reported percent moves to raw_used_percent.

§raw_used_percent: Option<f64>

The provider-reported percent when used_percent has been relaxed to an effective value (banked resets guarantee the window resets before the wall).

Pace on used_percent, not on this. The effective number is the real headroom: a reset that is going to happen has already been accounted for. Treating this as the truer figure routes work away from an account whose credit is about to be spent — and the credit expires whether or not it is used, so the cautious-looking reading is the lossy one. Display it beside the effective number in a human-facing view, where a zero next to real consumption would otherwise look like a fault.

Emitted only where the two diverge, so its absence means they agree and falling back to used_percent is exact rather than approximate. Rendering a placeholder for absence would be wrong on every unrelaxed window, which is nearly all of them.

§resets_at: Option<String>

ISO 8601 / RFC 3339 timestamp when the window resets. Omitted when the provider reports no reset (e.g. an idle session window with nothing pending) — never fabricated.

§window_minutes: Option<i64>

Window length in minutes. Omitted when the provider does not report one; the consumer then paces on utilization alone rather than a burn rate.

§used_count: Option<f64>

Absolute consumed count in the window (e.g. tokens, requests). A count of things, so integral by contract, and only ever the upstream’s own figure — never recovered from a percentage and a cap (a derived figure can carry a disagreement between two provider endpoints while wearing a type that claims exactness). Omitted when the upstream reports only a percentage. Human-facing UIs can show “10,336 / 40,000” alongside the percentage for richer context.

§total_count: Option<f64>

Absolute total cap for the window, when the upstream states one. May appear without used_count: the cap can be known while the consumed figure is only a percentage.

§regeneration: Option<Regeneration>

How the window’s quota comes back, when the upstream STATES a mechanic.

Absence licenses nothing. It means the upstream said nothing about replenishment — never “this is a fixed window”. Most providers state nothing, so absence is the common case and carries no information.

Trait Implementations§

Source§

impl Clone for RateWindow

Source§

fn clone(&self) -> RateWindow

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 RateWindow

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RateWindow

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for RateWindow

Source§

fn eq(&self, other: &RateWindow) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for RateWindow

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RateWindow

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.