pub struct RateLimiter { /* private fields */ }Expand description
Rate limiter using token bucket algorithm
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn new(permits_per_second: u32) -> Self
pub fn new(permits_per_second: u32) -> Self
Create a new rate limiter with specified permits per second
Sourcepub async fn acquire(&mut self) -> RatePermit
pub async fn acquire(&mut self) -> RatePermit
Acquire a permit to perform an operation
Sourcepub fn try_acquire(&mut self) -> Option<RatePermit>
pub fn try_acquire(&mut self) -> Option<RatePermit>
Try to acquire a permit without waiting
Auto Trait Implementations§
impl Freeze for RateLimiter
impl RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnsafeUnpin for RateLimiter
impl UnwindSafe for RateLimiter
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