Skip to main content

CacheAwareRateLimiter

Trait CacheAwareRateLimiter 

Source
pub trait CacheAwareRateLimiter:
    Send
    + Sync
    + 'static {
    // Required methods
    fn until_key_ready(
        &self,
        key: &str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>;
    fn check_key(&self, key: &str) -> bool;
}
Available on crate feature rate-limiting only.
Expand description

A trait for rate limiting that can be implemented by different rate limiting strategies

Required Methods§

Source

fn until_key_ready( &self, key: &str, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

Wait until a request to the given key (typically a domain or URL) is allowed This method should block until the rate limit allows the request to proceed

Source

fn check_key(&self, key: &str) -> bool

Check if a request to the given key would be allowed without blocking Returns true if the request can proceed immediately, false if it would be rate limited

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§