pub enum RateLimitState {
Ready,
RateLimited {
since: u64,
until_estimate: u64,
kind: RateLimitType,
},
}Expand description
Current rate-limit state of a client.
Unlike ClientEvent subscriptions (which report transitions), this is a snapshot that can
be queried synchronously via SharedEventBroadcaster::rate_limit_state or awaited via the
watch channel from SharedEventBroadcaster::watch_rate_limit_state. It is derived
automatically from the events flowing through the broadcaster, so every detection and retry
path keeps it up to date.
Variants§
Ready
No rate limiting currently in effect.
RateLimited
The client is rate limited and expected to be parked until until_estimate.
Fields
until_estimate: u64Best-estimate time at which operation will resume (seconds since Unix epoch). Updated as retries re-detect the limit and extend the backoff.
kind: RateLimitTypeHow the rate limit was detected.
Implementations§
Source§impl RateLimitState
impl RateLimitState
Sourcepub fn is_rate_limited_at(&self, now_unix: u64) -> bool
pub fn is_rate_limited_at(&self, now_unix: u64) -> bool
Whether the state indicates active rate limiting at now_unix (seconds since epoch).
Returns false once now_unix has passed until_estimate, even if no event has
transitioned the state back to RateLimitState::Ready yet.
Sourcepub fn remaining_at(&self, now_unix: u64) -> Option<Duration>
pub fn remaining_at(&self, now_unix: u64) -> Option<Duration>
Time remaining until the estimated resume point, if currently rate limited.
Trait Implementations§
Source§impl Clone for RateLimitState
impl Clone for RateLimitState
Source§fn clone(&self) -> RateLimitState
fn clone(&self) -> RateLimitState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RateLimitState
impl Debug for RateLimitState
Source§impl Default for RateLimitState
impl Default for RateLimitState
Source§fn default() -> RateLimitState
fn default() -> RateLimitState
Source§impl<'de> Deserialize<'de> for RateLimitState
impl<'de> Deserialize<'de> for RateLimitState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for RateLimitState
Source§impl PartialEq for RateLimitState
impl PartialEq for RateLimitState
Source§impl Serialize for RateLimitState
impl Serialize for RateLimitState
impl StructuralPartialEq for RateLimitState
Auto Trait Implementations§
impl Freeze for RateLimitState
impl RefUnwindSafe for RateLimitState
impl Send for RateLimitState
impl Sync for RateLimitState
impl Unpin for RateLimitState
impl UnsafeUnpin for RateLimitState
impl UnwindSafe for RateLimitState
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.