diff --git a/twilight-http-ratelimiting/src/lib.rs b/twilight-http-ratelimiting/src/lib.rs index 3607ed09c1..b7a5ac1fb9 100644 --- a/twilight-http-ratelimiting/src/lib.rs +++ b/twilight-http-ratelimiting/src/lib.rs @@ -250,6 +250,18 @@ pub struct Bucket { pub reset_at: Instant, } +impl Bucket { + /// Whether the bucket is exhausted. + pub const fn is_exhausted(&self) -> bool { + self.remaining == 0 + } + + /// Duration until the bucket resets. + pub fn reset_after(&self) -> Duration { + self.reset_at.saturating_duration_since(Instant::now()) + } +} + /// Actor run closure pre-enqueue for early [`MaybePermitFuture`] cancellation. type Predicate = Box) -> bool + Send>;