pub trait HttpCacheStreamInterface: Send + Sync {
type Body: Body + Send + 'static;
// Required methods
fn analyze_request(
&self,
parts: &Parts,
mode_override: Option<CacheMode>,
) -> Result<CacheAnalysis>;
async fn lookup_cached_response(
&self,
key: &str,
) -> Result<Option<(Response<Self::Body>, CachePolicy)>>
where <Self::Body as Body>::Data: Send,
<Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static;
async fn process_response<B>(
&self,
analysis: CacheAnalysis,
response: Response<B>,
) -> Result<Response<Self::Body>>
where B: Body + Send + 'static,
B::Data: Send,
B::Error: Into<StreamingError>,
<Self::Body as Body>::Data: Send,
<Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static;
fn prepare_conditional_request(
&self,
parts: &mut Parts,
cached_response: &Response<Self::Body>,
policy: &CachePolicy,
) -> Result<()>;
async fn handle_not_modified(
&self,
cached_response: Response<Self::Body>,
fresh_parts: &Parts,
) -> Result<Response<Self::Body>>
where <Self::Body as Body>::Data: Send,
<Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static;
}Expand description
Streaming version of the HTTP cache interface that supports streaming request/response bodies without buffering them in memory. This is ideal for large responses or when memory usage is a concern.
Required Associated Types§
Required Methods§
Sourcefn analyze_request(
&self,
parts: &Parts,
mode_override: Option<CacheMode>,
) -> Result<CacheAnalysis>
fn analyze_request( &self, parts: &Parts, mode_override: Option<CacheMode>, ) -> Result<CacheAnalysis>
Analyze a request to determine cache behavior
Sourceasync fn lookup_cached_response(
&self,
key: &str,
) -> Result<Option<(Response<Self::Body>, CachePolicy)>>
async fn lookup_cached_response( &self, key: &str, ) -> Result<Option<(Response<Self::Body>, CachePolicy)>>
Look up a cached response for the given cache key, returning a streaming body
Sourceasync fn process_response<B>(
&self,
analysis: CacheAnalysis,
response: Response<B>,
) -> Result<Response<Self::Body>>
async fn process_response<B>( &self, analysis: CacheAnalysis, response: Response<B>, ) -> Result<Response<Self::Body>>
Process a fresh response from upstream and potentially cache it with streaming support
Sourcefn prepare_conditional_request(
&self,
parts: &mut Parts,
cached_response: &Response<Self::Body>,
policy: &CachePolicy,
) -> Result<()>
fn prepare_conditional_request( &self, parts: &mut Parts, cached_response: &Response<Self::Body>, policy: &CachePolicy, ) -> Result<()>
Update request headers for conditional requests (e.g., If-None-Match)
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.