Struct ratelimit::Builder [] [src]

pub struct Builder { /* fields omitted */ }

A builder for a rate limiter.

Methods

impl Builder
[src]

[src]

Creates a new Builder with the default config

Examples

let mut b = Builder::new();

[src]

Returns a Limiter from the Builder.

Example


let mut r = Builder::new().build();

[src]

Sets the number of tokens to add per interval.

Examples


let mut r = Limiter::configure()
    .quantum(100)
    .build();

[src]

Sets the number of tokens that the bucket can hold.

Examples


let mut r = Limiter::configure()
    .capacity(100)
    .build();

[src]

Set the duration between token adds.

Examples


let mut r = Limiter::configure()
    .interval(Duration::new(2, 0))
    .build();

[src]

Alternative to interval; sets the number of times that tokens will be added to the bucket each second.

Examples


let mut rate = 100_000; // 100kHz
let mut r = Limiter::configure()
    .frequency(rate)
    .build();

Trait Implementations

impl Default for Builder
[src]

[src]

Returns the "default value" for a type. Read more