token-bucket 11.0.0

Zero-dependency, lock-free atomic GCRA, Fixed-Window, Token-Bucket, and 64-way sharded bounded keyed rate-limiting engine.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/// Outcome of a rate-limit evaluation with exact nanosecond reset and retry timings.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct RateLimitDecision {
    /// Whether the request was admitted.
    pub(crate) allowed: bool,
    /// Remaining tokens or quota units available after evaluation.
    pub(crate) remaining: u64,
    /// Nanoseconds until the quota fully resets or refills to capacity.
    pub(crate) reset_after_ns: u64,
    /// Nanoseconds to wait before retrying (`0` when allowed, `u64::MAX` when cost exceeds burst).
    pub(crate) retry_after_ns: u64,
    /// Configured burst or per-window limit associated with this evaluation.
    pub(crate) limit: u64,
}