pub struct SlidingWindow { /* private fields */ }Expand description
Sliding window rate limiter
Tracks actual execution timestamps and counts executions within a sliding window. More accurate than token bucket but uses more memory.
Implementations§
Source§impl SlidingWindow
impl SlidingWindow
Trait Implementations§
Source§impl Debug for SlidingWindow
impl Debug for SlidingWindow
Source§impl RateLimiter for SlidingWindow
impl RateLimiter for SlidingWindow
Source§fn try_acquire(&mut self) -> bool
fn try_acquire(&mut self) -> bool
Try to acquire a permit to execute a task Read more
Source§fn time_until_available(&self) -> Duration
fn time_until_available(&self) -> Duration
Get the time until a permit will be available
Source§fn available_permits(&self) -> u32
fn available_permits(&self) -> u32
Get the current number of available permits
Source§fn config(&self) -> &RateLimitConfig
fn config(&self) -> &RateLimitConfig
Get current configuration
Auto Trait Implementations§
impl Freeze for SlidingWindow
impl RefUnwindSafe for SlidingWindow
impl Send for SlidingWindow
impl Sync for SlidingWindow
impl Unpin for SlidingWindow
impl UnwindSafe for SlidingWindow
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