Skip to main content

RateLimitStore

Trait RateLimitStore 

Source
pub trait RateLimitStore: Send + Sync {
    // Required method
    fn hit<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        rate: &'life2 Rate,
    ) -> Pin<Box<dyn Future<Output = Decision> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

A backend that records request hits and decides whether each is allowed.

Required Methods§

Source

fn hit<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, rate: &'life2 Rate, ) -> Pin<Box<dyn Future<Output = Decision> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Record one hit for key and return the limiting decision for rate.

A store that cannot reach its backend should fail open (allow the request) rather than reject legitimate traffic.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§