pub struct RateLimitInfo {
pub limit: Option<u32>,
pub remaining: Option<u32>,
pub reset_after: Option<Duration>,
pub retry_after: Option<Duration>,
pub is_rate_limited: bool,
}Expand description
Parsed rate limit information from HTTP response headers.
Fields§
§limit: Option<u32>Maximum requests/CU allowed in the window.
remaining: Option<u32>Remaining requests/CU in the current window.
reset_after: Option<Duration>Time until the rate limit window resets.
retry_after: Option<Duration>Suggested backoff duration from Retry-After header.
is_rate_limited: boolWhether a 429 status was received.
Implementations§
Source§impl RateLimitInfo
impl RateLimitInfo
Sourcepub fn from_headers<'a>(
headers: impl Iterator<Item = (&'a str, &'a str)>,
) -> Self
pub fn from_headers<'a>( headers: impl Iterator<Item = (&'a str, &'a str)>, ) -> Self
Parse rate limit headers from an HTTP header map.
Accepts an iterator of (name, value) pairs to avoid depending on
a specific HTTP crate.
Sourcepub fn should_backoff(&self) -> bool
pub fn should_backoff(&self) -> bool
Whether we should back off based on the parsed info.
Sourcepub fn suggested_wait(&self) -> Option<Duration>
pub fn suggested_wait(&self) -> Option<Duration>
Suggested wait duration based on available information.
Trait Implementations§
Source§impl Clone for RateLimitInfo
impl Clone for RateLimitInfo
Source§fn clone(&self) -> RateLimitInfo
fn clone(&self) -> RateLimitInfo
Returns a duplicate of the value. Read more
1.0.0 · 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 RateLimitInfo
impl Debug for RateLimitInfo
Source§impl Default for RateLimitInfo
impl Default for RateLimitInfo
Source§fn default() -> RateLimitInfo
fn default() -> RateLimitInfo
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RateLimitInfo
impl RefUnwindSafe for RateLimitInfo
impl Send for RateLimitInfo
impl Sync for RateLimitInfo
impl Unpin for RateLimitInfo
impl UnsafeUnpin for RateLimitInfo
impl UnwindSafe for RateLimitInfo
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