pub struct UsageWindow {
pub name: String,
pub label: Option<String>,
pub used_percent: Option<f64>,
pub used: Option<f64>,
pub limit: Option<f64>,
pub resets_at: Option<String>,
pub resets_at_unix: Option<i64>,
pub window_seconds: Option<i64>,
}Expand description
A single rate-limit or quota window. Providers report usage either as a
percentage (used_percent) or as absolute counts (used / limit); a
window carries whichever the upstream gives. Reset time is kept verbatim as
an ISO-8601 string (resets_at) and/or unix seconds (resets_at_unix).
Fields§
§name: StringWindow id ("five_hour", "seven_day", "primary", a model id, …).
label: Option<String>Human-readable upstream label when name is generated.
used_percent: Option<f64>§used: Option<f64>§limit: Option<f64>§resets_at: Option<String>ISO-8601 reset timestamp, when the provider gives one.
resets_at_unix: Option<i64>Unix-seconds reset timestamp, when the provider gives one.
window_seconds: Option<i64>Window length in seconds, when known.
Implementations§
Source§impl UsageWindow
impl UsageWindow
Sourcepub fn percent(name: impl Into<String>, used_percent: f64) -> Self
pub fn percent(name: impl Into<String>, used_percent: f64) -> Self
A percentage-based window (used_percent in [0, 100]).
Sourcepub fn amounts(name: impl Into<String>, used: f64, limit: f64) -> Self
pub fn amounts(name: impl Into<String>, used: f64, limit: f64) -> Self
An absolute-count window (used / limit).
Sourcepub fn resets_iso(self, iso: impl Into<String>) -> Self
pub fn resets_iso(self, iso: impl Into<String>) -> Self
Attach an ISO-8601 reset timestamp.
Sourcepub fn resets_unix(self, unix: i64) -> Self
pub fn resets_unix(self, unix: i64) -> Self
Attach a unix-seconds reset timestamp.
Sourcepub fn window_secs(self, seconds: i64) -> Self
pub fn window_secs(self, seconds: i64) -> Self
Attach the window length in seconds.
Trait Implementations§
Source§impl Clone for UsageWindow
impl Clone for UsageWindow
Source§fn clone(&self) -> UsageWindow
fn clone(&self) -> UsageWindow
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 UsageWindow
impl Debug for UsageWindow
Source§impl Default for UsageWindow
impl Default for UsageWindow
Source§fn default() -> UsageWindow
fn default() -> UsageWindow
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for UsageWindow
impl RefUnwindSafe for UsageWindow
impl Send for UsageWindow
impl Sync for UsageWindow
impl Unpin for UsageWindow
impl UnsafeUnpin for UsageWindow
impl UnwindSafe for UsageWindow
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