HttpCacheStreamInterface

Trait HttpCacheStreamInterface 

Source
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§

Source

type Body: Body + Send + 'static

The body type used by this cache implementation

Required Methods§

Source

fn analyze_request( &self, parts: &Parts, mode_override: Option<CacheMode>, ) -> Result<CacheAnalysis>

Analyze a request to determine cache behavior

Source

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,

Look up a cached response for the given cache key, returning a streaming body

Source

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,

Process a fresh response from upstream and potentially cache it with streaming support

Source

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)

Source

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,

Handle a 304 Not Modified response by returning the cached response

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.

Implementors§