pub struct RateLimitTracker { /* private fields */ }Implementations§
Source§impl RateLimitTracker
impl RateLimitTracker
Sourcepub fn record_request(&mut self)
pub fn record_request(&mut self)
Records a single request.
Sourcepub fn is_rate_limited(&mut self, rate_limit: f32) -> bool
pub fn is_rate_limited(&mut self, rate_limit: f32) -> bool
Checks whether the rate limit has been reached (millisecond resolution).
Sourcepub fn get_current_rate(&self) -> f32
pub fn get_current_rate(&self) -> f32
Returns the current request rate (millisecond resolution).
Sourcepub fn remaining_in_window(&self) -> Duration
pub fn remaining_in_window(&self) -> Duration
Remaining duration of the current window (used for waiting).
Sourcepub fn current_window_count(&self) -> u32
pub fn current_window_count(&self) -> u32
Number of requests counted in the current window (returns 0 if the window has expired).
Trait Implementations§
Source§impl Clone for RateLimitTracker
impl Clone for RateLimitTracker
Source§fn clone(&self) -> RateLimitTracker
fn clone(&self) -> RateLimitTracker
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RateLimitTracker
impl RefUnwindSafe for RateLimitTracker
impl Send for RateLimitTracker
impl Sync for RateLimitTracker
impl Unpin for RateLimitTracker
impl UnsafeUnpin for RateLimitTracker
impl UnwindSafe for RateLimitTracker
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