Struct async_speed_limit::limiter::Builder [−][src]
Builder for Limiter
.
Examples
use async_speed_limit::Limiter; use std::time::Duration; let limiter = <Limiter>::builder(1_048_576.0) .refill(Duration::from_millis(100)) .build();
Implementations
impl<C: Clock> Builder<C>
[src]
pub fn new(speed_limit: f64) -> Self
[src]
Creates a new limiter builder.
Use infinity to make the speed unlimited.
pub fn speed_limit(&mut self, speed_limit: f64) -> &mut Self
[src]
Sets the speed limit of the limiter.
Use infinity to make the speed unlimited.
Panics
The speed limit must be positive. Panics if the speed limit is negative, zero, or NaN.
pub fn refill(&mut self, dur: Duration) -> &mut Self
[src]
Sets the refill period of the limiter.
The default value is 0.1 s, which should be good for most use cases. The refill period is ignored if the speed is infinity.
Panics
The duration must not be zero, otherwise this method panics.
pub fn clock(&mut self, clock: C) -> &mut Self
[src]
Sets the clock instance used by the limiter.
pub fn build(&mut self) -> Limiter<C>
[src]
Builds the limiter.
Trait Implementations
Auto Trait Implementations
impl<C> RefUnwindSafe for Builder<C> where
C: RefUnwindSafe,
<C as Clock>::Instant: RefUnwindSafe,
C: RefUnwindSafe,
<C as Clock>::Instant: RefUnwindSafe,
impl<C> Send for Builder<C> where
C: Send,
<C as Clock>::Instant: Send,
C: Send,
<C as Clock>::Instant: Send,
impl<C> Sync for Builder<C> where
C: Sync,
<C as Clock>::Instant: Sync,
C: Sync,
<C as Clock>::Instant: Sync,
impl<C> Unpin for Builder<C> where
C: Unpin,
<C as Clock>::Instant: Unpin,
C: Unpin,
<C as Clock>::Instant: Unpin,
impl<C> UnwindSafe for Builder<C> where
C: UnwindSafe,
<C as Clock>::Instant: UnwindSafe,
C: UnwindSafe,
<C as Clock>::Instant: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,