async_rate_limit::limiters

Trait ThreadsafeVariableRateLimiter

Source
pub trait ThreadsafeVariableRateLimiter {
    // Required method
    fn wait_with_cost(&self, cost: usize) -> impl Future<Output = ()> + Send;
}
Expand description

A threadsafe cost-based rate limiter, where each call can be of a variable cost.

Calls that cost more than all potentially available permits WILL deadlock permanently.

See TokenBucketRateLimiter for a common use case.

Required Methods§

Source

fn wait_with_cost(&self, cost: usize) -> 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§