pub struct KeyRateLimit { /* private fields */ }Expand description
Rate limit state for a single key
Implementations§
Source§impl KeyRateLimit
impl KeyRateLimit
Sourcepub fn check_and_increment(
&mut self,
config: &RateLimitConfig,
) -> RateLimitResult
pub fn check_and_increment( &mut self, config: &RateLimitConfig, ) -> RateLimitResult
Check the rate limit and increment counters if allowed
Returns the result of the rate limit check.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this rate limit state has expired (inactive for over an hour)
Sourcepub fn minute_count(&self) -> u32
pub fn minute_count(&self) -> u32
Get the current minute count
Sourcepub fn hour_count(&self) -> u32
pub fn hour_count(&self) -> u32
Get the current hour count
Trait Implementations§
Source§impl Debug for KeyRateLimit
impl Debug for KeyRateLimit
Auto Trait Implementations§
impl Freeze for KeyRateLimit
impl RefUnwindSafe for KeyRateLimit
impl Send for KeyRateLimit
impl Sync for KeyRateLimit
impl Unpin for KeyRateLimit
impl UnwindSafe for KeyRateLimit
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