Skip to main content

token_bucket/decision/
struct.rs

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