pub struct RateLimitResult {
pub allowed: bool,
pub remaining: u64,
pub reset_at: Instant,
pub limit: u64,
pub retry_after: Option<Duration>,
}Expand description
Result of a rate limit check.
Fields§
§allowed: boolWhether the request was allowed.
remaining: u64Remaining requests in the current window.
reset_at: InstantWhen the next token becomes available.
limit: u64The total rate limit for this window.
retry_after: Option<Duration>When to retry if the request was rejected.
Implementations§
Source§impl RateLimitResult
impl RateLimitResult
Sourcepub fn remaining_burst(&self) -> u64
pub fn remaining_burst(&self) -> u64
Requests left in the burst budget, token-bucket style.
GCRA’s remaining counts conforming requests visible right now
(floor of available time-budget in emission intervals), which is 1
on a fresh key after its first request. Consumers porting from
fixed-window or token-bucket limiters — and clients reading
X-RateLimit-Remaining — expect the burst-consumed view instead:
limit - consumed, i.e. burst - 1 after the first request of a
full burst.
limit - remaining is exactly that value: remaining is the unused
time-budget fraction, so the difference is the consumed burst share.