pub struct UsageWindow {
pub utilization: f64,
pub resets_at: Option<SystemTime>,
pub reset_description: Option<String>,
pub status: Option<String>,
}Expand description
One named usage window inside a snapshot (5-hour, 7-day, etc.).
The window’s identity (5-hour vs 7-day vs 7-day-opus) is implicit
in which UsageSnapshot field holds the value - no in-struct label.
Fields§
§utilization: f64§resets_at: Option<SystemTime>§reset_description: Option<String>§status: Option<String>The provider’s own verdict on this window (allowed,
allowed_warning, rejected), when it stated one: a window can be
rejected below 100%, so the percentage alone cannot say it is spent.
Implementations§
Source§impl UsageWindow
impl UsageWindow
Sourcepub fn is_currently_limited(&self) -> bool
pub fn is_currently_limited(&self) -> bool
True when this window is currently at or beyond its plan cap
AND the reset time has not yet passed. The pair matters: a
100% utilization figure from a cached snapshot remains at 100%
after the reset window expires (the cache is stale by then),
so the predicate must consult resets_at to avoid forever
classifying an account as rate-limited based on a stale probe.
resets_at == None returns false: a window with no scheduled
reset cannot transition out of the limit, so treating it as
permanently limited would strand the account. The usage probe
emits resets_at = Some(...) whenever a window is real; the
None case shows up in tests + edge-case snapshots only.