pub struct RateLimiter { /* private fields */ }Expand description
Simple in-memory rate limiter.
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub fn is_allowed(&self, key: &str) -> bool
pub fn is_allowed(&self, key: &str) -> bool
Check if a request is allowed for the given key.
Sourcepub fn remaining_requests(&self, key: &str) -> u32
pub fn remaining_requests(&self, key: &str) -> u32
Get remaining requests for a key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RateLimiter
impl RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin 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