pub trait HttpCacheStreamInterface: Send + Sync {
type Body: Body + Send + 'static;
// Required methods
fn analyze_request(
&self,
parts: &Parts,
mode_override: Option<CacheMode>,
) -> Result<CacheAnalysis, Box<dyn Error + Send + Sync>>;
async fn lookup_cached_response(
&self,
key: &str,
) -> Result<Option<(Response<Self::Body>, CachePolicy)>, Box<dyn Error + Send + Sync>>
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>,
metadata: Option<Vec<u8>>,
) -> Result<Response<Self::Body>, Box<dyn Error + Send + Sync>>
where B: Body + Send + 'static,
<B as Body>::Data: Send,
<B as Body>::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<(), Box<dyn Error + Send + Sync>>;
async fn handle_not_modified(
&self,
cached_response: Response<Self::Body>,
fresh_parts: &Parts,
) -> Result<Response<Self::Body>, Box<dyn Error + Send + Sync>>
where <Self::Body as Body>::Data: Send,
<Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static;
}Available on crate feature
streaming only.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, Box<dyn Error + Send + Sync>>
fn analyze_request( &self, parts: &Parts, mode_override: Option<CacheMode>, ) -> Result<CacheAnalysis, Box<dyn Error + Send + Sync>>
Analyze a request to determine cache behavior
Sourceasync fn lookup_cached_response(
&self,
key: &str,
) -> Result<Option<(Response<Self::Body>, CachePolicy)>, Box<dyn Error + Send + Sync>>
async fn lookup_cached_response( &self, key: &str, ) -> Result<Option<(Response<Self::Body>, CachePolicy)>, Box<dyn Error + Send + Sync>>
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>,
metadata: Option<Vec<u8>>,
) -> Result<Response<Self::Body>, Box<dyn Error + Send + Sync>>
async fn process_response<B>( &self, analysis: CacheAnalysis, response: Response<B>, metadata: Option<Vec<u8>>, ) -> Result<Response<Self::Body>, Box<dyn Error + Send + Sync>>
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<(), Box<dyn Error + Send + Sync>>
fn prepare_conditional_request( &self, parts: &mut Parts, cached_response: &Response<Self::Body>, policy: &CachePolicy, ) -> Result<(), Box<dyn Error + Send + Sync>>
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.