pub struct RetryAfter { /* private fields */ }
Expand description
A monotonic expiration marker for rate limits.
RetryAfter
represents a point in time when a rate limit expires. It allows checking
whether the rate limit is still active or has expired, and calculating the remaining time
until expiration.
Implementations§
Source§impl RetryAfter
impl RetryAfter
Sourcepub fn from_secs(seconds: u64) -> Self
pub fn from_secs(seconds: u64) -> Self
Creates a new RetryAfter
instance that expires after the specified number of seconds.
Sourcepub fn remaining_at(self, at: Instant) -> Option<Duration>
pub fn remaining_at(self, at: Instant) -> Option<Duration>
Returns the remaining duration until the rate limit expires using the specified instant as the reference point.
If the rate limit has already expired at the given instant, returns None
.
Sourcepub fn remaining(self) -> Option<Duration>
pub fn remaining(self) -> Option<Duration>
Returns the remaining duration until the rate limit expires.
This uses the current instant as the reference point. If the rate limit has already
expired, returns None
.
Sourcepub fn remaining_seconds_at(self, at: Instant) -> u64
pub fn remaining_seconds_at(self, at: Instant) -> u64
Returns the remaining seconds until the rate limit expires using the specified instant as the reference point.
This method rounds up to the next second to ensure that rate limits are strictly enforced.
If the rate limit has already expired, returns 0
.
Sourcepub fn remaining_seconds(self) -> u64
pub fn remaining_seconds(self) -> u64
Returns the remaining seconds until the rate limit expires.
This uses the current instant as the reference point. If the rate limit
has already expired, returns 0
.
Sourcepub fn expired_at(self, at: Instant) -> bool
pub fn expired_at(self, at: Instant) -> bool
Returns whether this rate limit has expired at the specified instant.
Trait Implementations§
Source§impl Clone for RetryAfter
impl Clone for RetryAfter
Source§fn clone(&self) -> RetryAfter
fn clone(&self) -> RetryAfter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RetryAfter
impl Debug for RetryAfter
Source§impl FromStr for RetryAfter
impl FromStr for RetryAfter
Source§impl Hash for RetryAfter
impl Hash for RetryAfter
Source§impl Ord for RetryAfter
impl Ord for RetryAfter
Source§fn cmp(&self, other: &RetryAfter) -> Ordering
fn cmp(&self, other: &RetryAfter) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RetryAfter
impl PartialEq for RetryAfter
Source§impl PartialOrd for RetryAfter
impl PartialOrd for RetryAfter
impl Copy for RetryAfter
impl Eq for RetryAfter
impl StructuralPartialEq for RetryAfter
Auto Trait Implementations§
impl Freeze for RetryAfter
impl RefUnwindSafe for RetryAfter
impl Send for RetryAfter
impl Sync for RetryAfter
impl Unpin for RetryAfter
impl UnwindSafe for RetryAfter
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more