Skip to main content

KeyExtractor

Trait KeyExtractor 

Source
pub trait KeyExtractor: Clone {
    type Key: Display;

    // Required method
    fn extract<T>(
        &self,
        request: &Request<T>,
    ) -> Result<Self::Key, RateLimitError>;
}
Expand description

Extract a client key synchronously from a request.

A Rate Limiter owns one extractor. Normalize client identity once at this request boundary and return the resulting displayable key; do not chain multiple extractors inside the middleware.

Required Associated Types§

Source

type Key: Display

The type of the key.

Required Methods§

Source

fn extract<T>(&self, request: &Request<T>) -> Result<Self::Key, RateLimitError>

Extract the key from the request.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§