Struct ratelimit::Ratelimit [] [src]

pub struct Ratelimit { /* fields omitted */ }

Methods

impl Ratelimit
[src]

create a new default ratelimit instance

Example


let mut r = Ratelimit::new();

create a new Config for building a custom Ratelimit

Example


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

run the ratelimiter

Example


let mut r = Ratelimit::new();

let sender = r.clone_sender();
let _ = sender.try_send(());

r.run(); // invoke in a tight-loop in its own thread

return clone of SyncSender for client use

Example


let mut r = Ratelimit::new();

let sender = r.clone_sender();

match sender.try_send(()) {
    Ok(_) => {
        println!("not limited");
    },
    Err(_) => {
        println!("was limited");
    },
}

this call is the blocking API of Ratelimit

Example


let mut r = Ratelimit::new();
for i in -10..0 {
    println!("T {}...", i);
    r.block(1);
}
println!("Ignition!");

Trait Implementations

impl Default for Ratelimit
[src]

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