pub struct CachedRateLimits(/* private fields */);
Expand description
A thread-safe cache of rate limits with automatic expiration handling.
CachedRateLimits
wraps a RateLimits
collection with a mutex to allow safe
concurrent access from multiple threads. It automatically removes expired rate limits
when retrieving the current limits.
This is useful for maintaining a shared set of rate limits across multiple processing threads or tasks.
Implementations§
Source§impl CachedRateLimits
impl CachedRateLimits
Sourcepub fn add(&self, limit: RateLimit)
pub fn add(&self, limit: RateLimit)
Adds a rate limit to this collection.
This is a thread-safe wrapper around RateLimits::add
.
Sourcepub fn merge(&self, limits: RateLimits)
pub fn merge(&self, limits: RateLimits)
Merges rate limits from another collection into this one.
This is a thread-safe wrapper around RateLimits::merge
.
Sourcepub fn current_limits(&self) -> Arc<RateLimits>
pub fn current_limits(&self) -> Arc<RateLimits>
Returns a reference to the current rate limits.
This method automatically removes any expired rate limits before returning, ensuring that only active limits are included in the result.
Trait Implementations§
Source§impl Debug for CachedRateLimits
impl Debug for CachedRateLimits
Source§impl Default for CachedRateLimits
impl Default for CachedRateLimits
Source§fn default() -> CachedRateLimits
fn default() -> CachedRateLimits
Auto Trait Implementations§
impl !Freeze for CachedRateLimits
impl RefUnwindSafe for CachedRateLimits
impl Send for CachedRateLimits
impl Sync for CachedRateLimits
impl Unpin for CachedRateLimits
impl UnwindSafe for CachedRateLimits
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
§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