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§
Sourcetype Key: Clone + Eq + Hash + Send + Sync + 'static
type Key: Clone + Eq + Hash + Send + Sync + 'static
The extracted key type — must be usable as a governor keyed-limiter key.
Sourcetype KeyExtractionError: ResponseError + 'static
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§
Sourcefn extract(
&self,
req: &ServiceRequest,
) -> Result<Self::Key, Self::KeyExtractionError>
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".