pub trait RateLimiter: Send + Sync {
// Required method
fn acquire<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
Admission throttle: acquire().await returns when the caller is permitted to
start an external call. Object-safe; hold as Arc<dyn RateLimiter>.
Both TokenBucketLimiter and SemaphoreLimiter implement this trait.
The acquire() contract models admission (rate of starts), not
concurrency-with-hold. For true hold-until-done concurrency limiting,
prefer Pipeline::with_concurrency.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".