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

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

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

Creates a new limiter builder.

Use infinity to make the speed unlimited.

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.

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.

Sets the clock instance used by the limiter.

Builds the limiter.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.