pub trait Predicate {
type Subject;
// Required method
fn check<'life0, 'async_trait>(
&'life0 self,
subject: Self::Subject,
) -> Pin<Box<dyn Future<Output = PredicateResult<Self::Subject>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Trait for evaluating whether a subject should be cached.
Predicates are the core abstraction for cache decision logic. 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 predicate evaluates.
For request predicates, this is typically a request type. For response
predicates, this is typically a response type.
§Ownership
The check method takes ownership of the subject and returns it wrapped
in a PredicateResult. This allows the subject to flow through a chain
of predicates without cloning.
Required Associated Types§
Required Methods§
Sourcefn check<'life0, 'async_trait>(
&'life0 self,
subject: Self::Subject,
) -> Pin<Box<dyn Future<Output = PredicateResult<Self::Subject>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn check<'life0, 'async_trait>(
&'life0 self,
subject: Self::Subject,
) -> Pin<Box<dyn Future<Output = PredicateResult<Self::Subject>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Evaluate whether the subject should be cached.
Returns PredicateResult::Cacheable if the subject should be cached,
or PredicateResult::NonCacheable if it should bypass the cache.