Skip to main content

KeyExtractor

Trait KeyExtractor 

Source
pub trait KeyExtractor:
    Clone
    + Send
    + Sync
    + 'static {
    // Required method
    fn extract<B>(&self, req: &Request<B>) -> Option<String>;
}
Expand description

Trait for extracting a rate-limit key from an incoming request.

Implementations should return Some(key) when a key can be determined (e.g. from the peer IP or an API key header) and None when the key cannot be extracted — in which case the middleware returns a 500 error.

Required Methods§

Source

fn extract<B>(&self, req: &Request<B>) -> Option<String>

Returns the rate-limit bucket key for req, or None if the key cannot be determined.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§