pub struct InMemoryRateLimitStore { /* private fields */ }Expand description
In-memory rate limit store for testing
Not recommended for production use across multiple instances. Use Redis for distributed rate limiting.
Implementations§
Trait Implementations§
Source§impl Default for InMemoryRateLimitStore
impl Default for InMemoryRateLimitStore
Source§impl RateLimitStore for InMemoryRateLimitStore
impl RateLimitStore for InMemoryRateLimitStore
Source§fn check_and_increment<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
config: &'life2 RateLimitConfig,
) -> Pin<Box<dyn Future<Output = Result<RateLimitResult, RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn check_and_increment<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
config: &'life2 RateLimitConfig,
) -> Pin<Box<dyn Future<Output = Result<RateLimitResult, RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Check if an operation is allowed under the rate limit and increment counter Read more
Source§fn check<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
config: &'life2 RateLimitConfig,
) -> Pin<Box<dyn Future<Output = Result<RateLimitResult, RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn check<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
config: &'life2 RateLimitConfig,
) -> Pin<Box<dyn Future<Output = Result<RateLimitResult, RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get current rate limit status without incrementing
Source§fn reset<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
) -> Pin<Box<dyn Future<Output = Result<(), RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn reset<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
) -> Pin<Box<dyn Future<Output = Result<(), RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reset rate limit for a scope (useful for admin overrides)
Source§fn apply_penalty<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
penalty_secs: u64,
) -> Pin<Box<dyn Future<Output = Result<(), RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn apply_penalty<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
penalty_secs: u64,
) -> Pin<Box<dyn Future<Output = Result<(), RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Apply a penalty (temporary ban) for a scope
Source§fn is_penalized<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
) -> Pin<Box<dyn Future<Output = Result<bool, RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn is_penalized<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 RateLimitScope,
) -> Pin<Box<dyn Future<Output = Result<bool, RateLimitError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a scope is currently in penalty period
Auto Trait Implementations§
impl !RefUnwindSafe for InMemoryRateLimitStore
impl !UnwindSafe for InMemoryRateLimitStore
impl Freeze for InMemoryRateLimitStore
impl Send for InMemoryRateLimitStore
impl Sync for InMemoryRateLimitStore
impl Unpin for InMemoryRateLimitStore
impl UnsafeUnpin for InMemoryRateLimitStore
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