Skip to main content

RequestContextExt

Trait RequestContextExt 

Source
pub trait RequestContextExt {
    // Required methods
    fn with_enhanced_client_id(self, client_id: ClientId) -> Self;
    fn extract_client_id(
        self,
        extractor: &ClientIdExtractor,
        headers: Option<&HashMap<String, String>>,
        query_params: Option<&HashMap<String, String>>,
    ) -> Self;
    fn get_enhanced_client_id(&self) -> Option<ClientId>;
}
Expand description

Extension trait providing structured client-id handling.

The MCP transports capture a raw client_id string, but protocol-aware code often wants the richer super::client::ClientId enum (which tracks how the identity was proven — bearer token, session cookie, anonymous, etc.). This trait bridges the two.

Required Methods§

Source

fn with_enhanced_client_id(self, client_id: ClientId) -> Self

Set client_id from a structured super::client::ClientId and record the authentication method + authenticated flag in metadata.

Source

fn extract_client_id( self, extractor: &ClientIdExtractor, headers: Option<&HashMap<String, String>>, query_params: Option<&HashMap<String, String>>, ) -> Self

Extract a client ID from headers/query params and apply it via Self::with_enhanced_client_id.

Source

fn get_enhanced_client_id(&self) -> Option<ClientId>

Rehydrate the structured super::client::ClientId from the context.

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§