| Crates.io | rateflow |
| lib.rs | rateflow |
| version | 0.1.0 |
| created_at | 2026-01-05 05:23:29.254764+00 |
| updated_at | 2026-01-05 05:23:29.254764+00 |
| description | A declarative, flexible, and high-performance rate limiting library for Rust |
| homepage | https://github.com/M1tsumi/RateFlow |
| repository | https://github.com/M1tsumi/RateFlow |
| max_upload_size | |
| id | 2023146 |
| size | 75,474 |
A declarative, flexible, and high-performance rate limiting library for Rust.
Add to your Cargo.toml:
[dependencies]
rateflow = "0.1"
tokio = { version = "1", features = ["full"] }
use rateflow::{RateLimiter, Window};
// Create a rate limiter with 100 requests per minute
let limiter = RateLimiter::builder()
.limit(100)
.window(Window::Minute)
.build()
.unwrap();
// Check if a request is allowed
let client_id = "user@example.com";
if limiter.check(client_id).await {
// Process request
} else {
// Reject request
}
use rateflow::{RateLimiter, Window, Tier};
// Configure different limits for different user tiers
let limiter = RateLimiter::builder()
.add_tier(
Tier::new("free")
.limit(100)
.window(Window::Minute)
)
.add_tier(
Tier::new("premium")
.limit(1000)
.window(Window::Minute)
)
.build()
.unwrap();
// Check with tier information
if limiter.check_tier("free", "user@example.com").await {
// Process request
}
Apache 2