pub trait VariableCostRateLimiter {
// Required method
fn wait_with_cost(&mut self, cost: usize) -> impl Future<Output = ()> + Send;
}
Expand description
A 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§
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§
impl VariableCostRateLimiter for TokenBucketRateLimiter
impl<L: ThreadsafeVariableRateLimiter> VariableCostRateLimiter for L
All VariableCostRateLimiter
s are ThreadsafeVariableRateLimiter
s, since they can pass &mut self
as &self
.
This blanket implementation saves implementers from having to define the trait manually.