pub trait RateLimitSinkExt<T>: Sink<T> + Sized {
// Provided methods
fn rate_limit_per_unit(
self,
elements_per_unit: usize,
unit: Duration,
) -> (RateLimitedSink<Self>, RateController) { ... }
fn rate_limit_with_controller(
self,
controller: &RateController,
) -> RateLimitedSink<Self> { ... }
}Expand description
Extension trait to add rate limiting to any sink.
Provided Methods§
Sourcefn rate_limit_per_unit(
self,
elements_per_unit: usize,
unit: Duration,
) -> (RateLimitedSink<Self>, RateController)
fn rate_limit_per_unit( self, elements_per_unit: usize, unit: Duration, ) -> (RateLimitedSink<Self>, RateController)
Creates a rate-limited sink that allows ingesting items at the given rate.
The rate can be controlled dynamically during the lifetime of the sink by using
the returned RateController.
If elements_per_unit is 0, the sink will not ingest items until the limit is changed
using the RateController to a non-zero value.
Sourcefn rate_limit_with_controller(
self,
controller: &RateController,
) -> RateLimitedSink<Self>
fn rate_limit_with_controller( self, controller: &RateController, ) -> RateLimitedSink<Self>
Creates a rate-limited sink that allows ingesting items at the given rate.
The rate can be controlled dynamically during the lifetime of the sink by using
the given RateController.
If the controller has zero rate,
the sink will not ingest items until the limit is
changed using the RateController to a non-zero value.
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.