async_rate_limit::limiters

Trait RateLimiter

Source
pub trait RateLimiter {
    // Required method
    fn wait_until_ready(&mut self) -> impl Future<Output = ()> + Send;
}
Expand description

A per-call rate limiter, where each call has an implied cost of 1 permit.

See SlidingWindowRateLimiter for a common use case.

Required Methods§

Source

fn wait_until_ready(&mut self) -> impl Future<Output = ()> + Send

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<L: ThreadsafeRateLimiter> RateLimiter for L

All RateLimiters are ThreadsafeRateLimiters, since they can pass &mut self as &self.

This blanket implementation saves implementers from having to define the trait manually.