pub trait CacheableRequest: Sized {
// Required method
fn cache_policy<P, E>(
self,
predicates: P,
extractors: E,
) -> impl Future<Output = RequestCachePolicy<Self>> + Send
where P: Predicate<Subject = Self> + Send + Sync,
E: Extractor<Subject = Self> + Send + Sync;
}Expand description
Trait for request types that can participate in caching.
Implementations determine whether a request should be cached by applying predicates and extracting cache keys.
§Type Requirements
Request types must be Sized to allow ownership transfer through
the caching pipeline.
§Processing
The cache_policy method:
- Applies predicates to determine if the request is cacheable
- If cacheable, extracts a cache key using the provided extractors
- Returns either
Cacheablewith the key orNonCacheable
Required Methods§
Sourcefn cache_policy<P, E>(
self,
predicates: P,
extractors: E,
) -> impl Future<Output = RequestCachePolicy<Self>> + Send
fn cache_policy<P, E>( self, predicates: P, extractors: E, ) -> impl Future<Output = RequestCachePolicy<Self>> + Send
Determine if this request should be cached and extract its key.
§Arguments
predicates- Predicates to evaluate whether the request is cacheableextractors- Extractors to generate the cache key
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".