Skip to main content

RateLimitStore

Trait RateLimitStore 

Source
pub trait RateLimitStore:
    Send
    + Sync
    + 'static {
    // Required method
    fn check(&self, key: &str) -> RateLimitDecision;

    // Provided method
    fn purge_expired(&self) -> usize { ... }
}
Expand description

Pluggable rate-limit decision backend (in-memory sharded or external distributed store).

Required Methods§

Source

fn check(&self, key: &str) -> RateLimitDecision

Evaluates and records one request against key.

§Arguments
  • &str - Bucket partition key.
§Returns
  • RateLimitDecision - Admission decision and remaining quota metadata.

Provided Methods§

Source

fn purge_expired(&self) -> usize

Evicts stale expired bucket entries to bound memory usage.

§Returns
  • usize - Number of evicted entries.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§