pub struct InMemoryRateLimitStore { /* private fields */ }Expand description
In-memory rate-limit store intended for local development and single-process apps.
The store tracks counters in process memory and opportunistically removes
expired identity windows whenever RateLimitStore::check runs. It is not
shared across processes, not durable across restarts, and not a substitute
for a distributed limiter at multi-instance production boundaries.
Implementations§
Source§impl InMemoryRateLimitStore
impl InMemoryRateLimitStore
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of identity windows currently retained by the store.
Expired windows are pruned opportunistically during RateLimitStore::check,
so this value is mainly useful for tests, diagnostics, and local tools.
Trait Implementations§
Source§impl Clone for InMemoryRateLimitStore
impl Clone for InMemoryRateLimitStore
Source§fn clone(&self) -> InMemoryRateLimitStore
fn clone(&self) -> InMemoryRateLimitStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for InMemoryRateLimitStore
impl Default for InMemoryRateLimitStore
Source§fn default() -> InMemoryRateLimitStore
fn default() -> InMemoryRateLimitStore
Returns the “default value” for a type. Read more
Source§impl RateLimitStore for InMemoryRateLimitStore
impl RateLimitStore for InMemoryRateLimitStore
Source§fn check(
&self,
identity: &RequestIdentity,
limit: u64,
window: Duration,
) -> Result<RateLimitDecision, RateLimitError>
fn check( &self, identity: &RequestIdentity, limit: u64, window: Duration, ) -> Result<RateLimitDecision, RateLimitError>
Checks and consumes one request for an identity.
Auto Trait Implementations§
impl Freeze for InMemoryRateLimitStore
impl RefUnwindSafe for InMemoryRateLimitStore
impl Send for InMemoryRateLimitStore
impl Sync for InMemoryRateLimitStore
impl Unpin for InMemoryRateLimitStore
impl UnsafeUnpin 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