Struct ratelimit::Config [] [src]

pub struct Config {
    // some fields omitted
}

Methods

impl Config
[src]

fn build(self) -> Ratelimit

returns a Ratelimit from the Config

Example


let mut r = Ratelimit::configure().build();

fn quantum(self, quantum: u32) -> Self

sets the number of tokens to add per interval

Example


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

fn capacity(self, capacity: u32) -> Self

sets the bucket capacity

Example


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

fn interval(self, interval: Duration) -> Self

set the duration between token adds

Example


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

fn frequency(self, cycles: u32) -> Self

set the frequency in Hz of the ratelimiter

Example


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

Trait Implementations

impl Default for Config
[src]

fn default() -> Config

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