Skip to main content

RateLimitBackend

Trait RateLimitBackend 

Source
pub trait RateLimitBackend:
    Send
    + Sync
    + 'static {
    // Required method
    fn hit<'a>(
        &'a self,
        key: &'a str,
        max: u32,
        window_secs: u32,
    ) -> Pin<Box<dyn Future<Output = RateDecision> + Send + 'a>>;
}
Expand description

Shared counting backend (Redis, Memcached, …). Object-safe via BoxFuture, following the same pattern as SessionStore and OAuth2Provider.

Implementations MUST count-and-decide atomically in a single round-trip.

Required Methods§

Source

fn hit<'a>( &'a self, key: &'a str, max: u32, window_secs: u32, ) -> Pin<Box<dyn Future<Output = RateDecision> + Send + 'a>>

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§