async-rate-limiter
async-rate-limiter implements a token bucket algorithm that can be used to limit API access frequency.
Example
Update your Cargo.toml:
[]
# Change features to ["rt-async-std"] if you are using async-std runtime.
= { = "1.39.2", = ["rt-tokio"] }
Thanks to Rust’s async functionality, this crate is very simple to use. Just
put your function call after
RateLimiter::acquire().await,
then the function will be called with the specified rate limit.
Here is a simple example:
use RateLimiter;
use Duration;
async
async-rate-limiter can support different async runtimes, tokio & async-std are supported currently. You can use features to switch async runtimes.