Skip to main content

Extractor

Trait Extractor 

Source
pub trait Extractor {
    type Subject;

    // Required method
    fn get<'life0, 'async_trait>(
        &'life0 self,
        subject: Self::Subject,
    ) -> Pin<Box<dyn Future<Output = KeyParts<Self::Subject>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for extracting cache key components from a subject.

Extractors are the mechanism for building cache keys from requests. They are protocol-agnostic - the same trait works for HTTP requests, gRPC messages, or any other protocol type.

§Type Parameters

The Subject associated type defines what this extractor processes. Typically this is a request type from which cache key components are extracted.

§Ownership

The get method takes ownership of the subject and returns it wrapped in KeyParts along with the extracted key components. This allows extractors to be chained without cloning.

§Blanket Implementations

This trait is implemented for:

  • &T where T: Extractor
  • Box<T> where T: Extractor
  • Arc<T> where T: Extractor

Required Associated Types§

Source

type Subject

The type from which cache key components are extracted.

Required Methods§

Source

fn get<'life0, 'async_trait>( &'life0 self, subject: Self::Subject, ) -> Pin<Box<dyn Future<Output = KeyParts<Self::Subject>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Extract cache key components from the subject.

Returns a KeyParts containing the subject and accumulated key parts.

Implementations on Foreign Types§

Source§

impl<T> Extractor for &T
where T: Extractor + ?Sized + Sync, T::Subject: Send,

Source§

type Subject = <T as Extractor>::Subject

Source§

fn get<'life0, 'async_trait>( &'life0 self, subject: T::Subject, ) -> Pin<Box<dyn Future<Output = KeyParts<T::Subject>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T> Extractor for Box<T>
where T: Extractor + ?Sized + Sync, T::Subject: Send,

Source§

type Subject = <T as Extractor>::Subject

Source§

fn get<'life0, 'async_trait>( &'life0 self, subject: T::Subject, ) -> Pin<Box<dyn Future<Output = KeyParts<T::Subject>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T> Extractor for Arc<T>
where T: Extractor + Send + Sync + ?Sized, T::Subject: Send,

Source§

type Subject = <T as Extractor>::Subject

Source§

fn get<'life0, 'async_trait>( &'life0 self, subject: T::Subject, ) -> Pin<Box<dyn Future<Output = KeyParts<T::Subject>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§