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§
Sourcefn 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 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
Sourcefn 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 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
Sourcefn 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 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
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".