Struct async_speed_limit::limiter::Builder[][src]

pub struct Builder<C: Clock> { /* fields omitted */ }

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

impl<C: Debug + Clock> Debug for Builder<C> where
    C::Instant: Debug
[src]

Auto Trait Implementations

impl<C> RefUnwindSafe for Builder<C> where
    C: RefUnwindSafe,
    <C as Clock>::Instant: RefUnwindSafe

impl<C> Send for Builder<C> where
    C: Send,
    <C as Clock>::Instant: Send

impl<C> Sync for Builder<C> where
    C: Sync,
    <C as Clock>::Instant: Sync

impl<C> Unpin for Builder<C> where
    C: Unpin,
    <C as Clock>::Instant: Unpin

impl<C> UnwindSafe for Builder<C> where
    C: UnwindSafe,
    <C as Clock>::Instant: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.