pub struct RateLimitInfo {
pub limit: Option<u64>,
pub remaining: Option<u64>,
pub reset_secs: Option<u64>,
pub cost: Option<u64>,
}Expand description
Rate limit information extracted from response headers.
Envoy’s rate limiter returns these headers in the IETF draft format:
x-ratelimit-limit: e.g."50, 50;w=60"(total quota for the window)x-ratelimit-remaining: e.g."40"(remaining budget in window)x-ratelimit-reset: e.g."41"(seconds until window resets)x-ratelimit-cost: e.g."10"(budget consumed per request)
Fields§
§limit: Option<u64>Total request quota for the current window.
Parsed from x-ratelimit-limit. For IETF draft format like "50, 50;w=60",
the first integer before the comma is used.
remaining: Option<u64>Remaining budget in the current window.
Parsed from x-ratelimit-remaining. Note this is budget units, not request count.
Divide by cost to get the number of requests remaining.
reset_secs: Option<u64>Seconds until the rate limit window resets.
Parsed from x-ratelimit-reset.
cost: Option<u64>Budget consumed per request.
Parsed from x-ratelimit-cost. For example, if limit is 50 and cost is 10,
you can make 5 requests per window.
Implementations§
Source§impl RateLimitInfo
impl RateLimitInfo
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Returns true if the rate limit quota has been exhausted.
Sourcepub fn suggested_wait_secs(&self) -> Option<u64>
pub fn suggested_wait_secs(&self) -> Option<u64>
Returns the suggested number of seconds to wait before making another request.
Trait Implementations§
Source§impl Clone for RateLimitInfo
impl Clone for RateLimitInfo
Source§fn clone(&self) -> RateLimitInfo
fn clone(&self) -> RateLimitInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.