Struct ratelimit_meter::Limiter [] [src]

pub struct Limiter { /* fields omitted */ }

A builder object that can be used to construct rate-limiters as meters.

Methods

impl Limiter
[src]

A builder pattern implementation that can construct deciders.

Basic example

This example constructs a decider that considers every cell compliant:


let mut limiter = Limiter::new().build::<Allower>().unwrap();
for _i in 1..3 {
    println!("{:?}...", limiter.check());
}

[src]

Returns a default (useless) limiter without a capacity or cell weight, and a time_unit of 1 second.

[src]

Sets the capacity of the limiter's "bucket" in elements per time_unit.

See time_unit.

[src]

Sets the "weight" of each cell being checked against the bucket. Each cell fills the bucket by this much.

[src]

Sets the "unit of time" within which the bucket drains.

The assumption is that in a period of time_unit (if no cells are being checked), the bucket is fully drained.

[src]

Builds and returns a concrete structure that implements the Decider trait.