pub trait RateLimiterKeyed<K>: Sync{
// Required methods
fn acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Token> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn acquire_timeout<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
duration: Duration,
) -> Pin<Box<dyn Future<Output = Option<Token>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn release<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
token: Token,
outcome: Option<RequestOutcome>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Controls the rate of requests over time with per-key rate limiting.
Each key maintains its own rate limit state, allowing for independent rate limiting across different clients, users, or request types.
Required Methods§
Sourcefn acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Token> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = Token> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Acquire permission to make a request for a specific key. Waits until a token is available.
Sourcefn acquire_timeout<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
duration: Duration,
) -> Pin<Box<dyn Future<Output = Option<Token>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn acquire_timeout<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
duration: Duration,
) -> Pin<Box<dyn Future<Output = Option<Token>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Acquire permission to make a request for a specific key with a timeout. Returns a token if successful.
Sourcefn release<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
token: Token,
outcome: Option<RequestOutcome>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn release<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
token: Token,
outcome: Option<RequestOutcome>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Release the token and record the outcome of the request for the specific key. The response time is calculated from when the token was acquired.