pub struct InMemoryRateLimitStore { /* private fields */ }Expand description
In-memory rate limit store.
Uses a HashMap protected by a Mutex for thread-safe access.
Suitable for single-process deployments. For distributed systems,
implement a custom store using Redis or similar.
Implementations§
Source§impl InMemoryRateLimitStore
impl InMemoryRateLimitStore
Sourcepub fn check(
&self,
key: &str,
algorithm: RateLimitAlgorithm,
max_requests: u64,
window: Duration,
) -> RateLimitResult
pub fn check( &self, key: &str, algorithm: RateLimitAlgorithm, max_requests: u64, window: Duration, ) -> RateLimitResult
Check and consume a request against the rate limit.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for InMemoryRateLimitStore
impl !RefUnwindSafe for InMemoryRateLimitStore
impl Send for InMemoryRateLimitStore
impl Sync for InMemoryRateLimitStore
impl Unpin for InMemoryRateLimitStore
impl UnwindSafe 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).