Skip to main content

KeyExtractor

Trait KeyExtractor 

Source
pub trait KeyExtractor: Clone + 'static {
    type Key: Clone + Eq + Hash + Send + Sync + 'static;
    type KeyExtractionError: ResponseError + 'static;

    // Required method
    fn extract(
        &self,
        req: &ServiceRequest,
    ) -> Result<Self::Key, Self::KeyExtractionError>;
}
Expand description

Extracts the rate-limiting key from an incoming request.

Mirrors the one piece of actix_governor::KeyExtractor’s shape bamboo actually used, so config::ClientIpKeyExtractor ports over with no change to its extraction logic — only its error type moves to SimpleKeyExtractionError below.

Required Associated Types§

Source

type Key: Clone + Eq + Hash + Send + Sync + 'static

The extracted key type — must be usable as a governor keyed-limiter key.

Source

type KeyExtractionError: ResponseError + 'static

The error returned when extraction fails; converts to the response a caller sees (via actix_web::Error’s blanket From<ResponseError>).

Required Methods§

Source

fn extract( &self, req: &ServiceRequest, ) -> Result<Self::Key, Self::KeyExtractionError>

Extract the key, or fail with a response-producing error.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§