pub enum RateLimitBehavior {
BlockAndRetry,
ReturnError,
}Expand description
How the client should react when a rate limit is detected.
This controls what happens after detection; detection itself (status codes,
response-body patterns) is configured via RateLimitConfig and always broadcasts
ClientEvent::RateLimited and updates the shared RateLimitState regardless of
the behavior selected here.
§Queue-building usage
RateLimitBehavior::ReturnError is intended for callers that maintain their own work
queue: instead of the client sleeping internally, operations fail fast with
LastFmError::RateLimit. The caller can then watch
SharedEventBroadcaster::watch_rate_limit_state (or the client’s
watch_rate_limit_state()) for the “paused until T” estimate and schedule retries itself.
See LastFmEditClientImpl::non_blocking() for a convenient way to derive such a client.
Variants§
BlockAndRetry
Default behavior: internally sleep and retry (subject to RetryConfig) when a rate
limit is detected. Callers block until the operation succeeds or retries are exhausted.
ReturnError
Never sleep or retry internally on rate limits. Operations return
LastFmError::RateLimit immediately so the caller can
queue the work and schedule its own retry (e.g. by watching RateLimitState).
Trait Implementations§
Source§impl Clone for RateLimitBehavior
impl Clone for RateLimitBehavior
Source§fn clone(&self) -> RateLimitBehavior
fn clone(&self) -> RateLimitBehavior
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RateLimitBehavior
Source§impl Debug for RateLimitBehavior
impl Debug for RateLimitBehavior
Source§impl Default for RateLimitBehavior
impl Default for RateLimitBehavior
Source§fn default() -> RateLimitBehavior
fn default() -> RateLimitBehavior
impl Eq for RateLimitBehavior
Source§impl PartialEq for RateLimitBehavior
impl PartialEq for RateLimitBehavior
impl StructuralPartialEq for RateLimitBehavior
Auto Trait Implementations§
impl Freeze for RateLimitBehavior
impl RefUnwindSafe for RateLimitBehavior
impl Send for RateLimitBehavior
impl Sync for RateLimitBehavior
impl Unpin for RateLimitBehavior
impl UnsafeUnpin for RateLimitBehavior
impl UnwindSafe for RateLimitBehavior
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<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.