Struct rate_limiter::rate_limiter::RateLimiter[][src]

pub struct RateLimiter<T> { /* fields omitted */ }

Implementations

Rate limit

Examples

use rate_limiter::rate_limiter::Store;
use rate_limiter::RateLimiter;
use rate_limiter::rate_limiter::to_second;
let mut store = Store::new();
let mut rate_limiter = RateLimiter::new(&mut store);
let rs = rate_limiter.rate_limit("foo".to_string(),10,1,1,1).unwrap();
assert_eq!(rs.allowed, true);
assert_eq!(rs.remaining, 10);
assert_eq!(rs.limit, 11);
assert_eq!(to_second(rs.retry_after), -1);
assert_eq!(to_second(rs.reset_after), 1);

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.