pub struct Bucket { /* private fields */ }
Expand description
A bucket containing ratelimiting information for a Path
.
Implementations§
source§impl Bucket
impl Bucket
sourcepub const fn new(
limit: u64,
remaining: u64,
reset_after: Duration,
started_at: Option<Instant>,
) -> Self
pub const fn new( limit: u64, remaining: u64, reset_after: Duration, started_at: Option<Instant>, ) -> Self
Create a representation of a ratelimiter bucket.
Buckets are returned by ratelimiters via Ratelimiter::bucket
method.
Its primary use is for informational purposes, including information
such as the number of remaining tickets or determining
how much time remains
until the bucket interval resets.
sourcepub const fn reset_after(&self) -> Duration
pub const fn reset_after(&self) -> Duration
Duration after the Self::started_at
time the bucket will
refresh.
sourcepub const fn started_at(&self) -> Option<Instant>
pub const fn started_at(&self) -> Option<Instant>
When the bucket’s ratelimit refresh countdown started.
sourcepub fn time_remaining(&self) -> Option<Duration>
pub fn time_remaining(&self) -> Option<Duration>
How long until the bucket will refresh.
May return None
if the refresh timer has not been started yet or
the bucket has already refreshed.
Auto Trait Implementations§
impl Freeze for Bucket
impl RefUnwindSafe for Bucket
impl Send for Bucket
impl Sync for Bucket
impl Unpin for Bucket
impl UnwindSafe for Bucket
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more