Skip to main content

RateLimiter

Trait RateLimiter 

Source
pub trait RateLimiter:
    Debug
    + Send
    + Sync {
    // Required method
    fn allow<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 RateLimitKey,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

Per-source rate-limiting port (M49).

Returns true when the call is admitted (under quota), false when rate-limited. Adapters are responsible for atomic check-and-decrement semantics — naive split shapes (check + decrement) leak admits under concurrent calls. Single-method enforces atomicity at the trait surface.

&self (not &mut self) so a single limiter serves many concurrent callers; interior mutability lives in the adapter.

Required Methods§

Source

fn allow<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 RateLimitKey, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Implementors§