Skip to main content

RateLimiter

Trait RateLimiter 

Source
pub trait RateLimiter: Send + Sync {
    // Required methods
    fn check_limit<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        client_id: &'life1 str,
        endpoint: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<RateLimitResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn record_request<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        client_id: &'life1 str,
        endpoint: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_status<'life0, 'life1, 'async_trait>(
        &'life0 self,
        client_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<RateLimitStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn reset_limits<'life0, 'life1, 'async_trait>(
        &'life0 self,
        client_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Rate limiter trait for server-side rate limiting

Required Methods§

Source

fn check_limit<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, client_id: &'life1 str, endpoint: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<RateLimitResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if request is within limits

Source

fn record_request<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, client_id: &'life1 str, endpoint: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Record request for rate limiting

Source

fn get_status<'life0, 'life1, 'async_trait>( &'life0 self, client_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<RateLimitStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get rate limit status

Source

fn reset_limits<'life0, 'life1, 'async_trait>( &'life0 self, client_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reset rate limits for client

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§