Struct ratelimit::Builder
[−]
[src]
pub struct Builder { /* fields omitted */ }
A builder for a rate limiter.
Methods
impl Builder
[src]
fn new() -> Builder
[src]
fn build(self) -> Limiter
[src]
fn quantum(self, quantum: u32) -> Self
[src]
Sets the number of tokens to add per interval.
Examples
let mut r = Limiter::configure() .quantum(100) .build();
fn capacity(self, capacity: u32) -> Self
[src]
Sets the number of tokens that the bucket can hold.
Examples
let mut r = Limiter::configure() .capacity(100) .build();
fn interval(self, interval: Duration) -> Self
[src]
Set the duration between token adds.
Examples
let mut r = Limiter::configure() .interval(Duration::new(2, 0)) .build();
fn frequency(self, cycles: u32) -> Self
[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();