Skip to main content

KeyExtractor

Trait KeyExtractor 

Source
pub trait KeyExtractor:
    Send
    + Sync
    + 'static {
    // Required method
    fn extract(&self, stream: &Stream, ctx: &Context) -> String;
}
Expand description

Extracts the rate-limiting partition key (for example client IP, API key, or user + route).

Required Methods§

Source

fn extract(&self, stream: &Stream, ctx: &Context) -> String

Computes the bucket key for an incoming request.

§Arguments
  • &Stream - Underlying transport stream (for peer socket address inspection).
  • &Context - Request and response context.
§Returns
  • String - Partition key identifying the rate-limit bucket.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§