StreamingCacheManager

Trait StreamingCacheManager 

Source
pub trait StreamingCacheManager:
    Send
    + Sync
    + 'static {
    type Body: Body + Send + 'static;

    // Required methods
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cache_key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<(Response<Self::Body>, CachePolicy)>>> + Send + 'async_trait>>
       where <Self::Body as Body>::Data: Send,
             <Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn put<'life0, 'async_trait, B>(
        &'life0 self,
        cache_key: String,
        response: Response<B>,
        policy: CachePolicy,
        request_url: Url,
    ) -> Pin<Box<dyn Future<Output = Result<Response<Self::Body>>> + Send + 'async_trait>>
       where B: Body + Send + 'static + 'async_trait,
             B::Data: Send,
             B::Error: Into<StreamingError>,
             <Self::Body as Body>::Data: Send,
             <Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn convert_body<'life0, 'async_trait, B>(
        &'life0 self,
        response: Response<B>,
    ) -> Pin<Box<dyn Future<Output = Result<Response<Self::Body>>> + Send + 'async_trait>>
       where B: Body + Send + 'static + 'async_trait,
             B::Data: Send,
             B::Error: Into<StreamingError>,
             <Self::Body as Body>::Data: Send,
             <Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cache_key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A streaming cache manager that supports streaming request/response bodies without buffering them in memory. This is ideal for large responses.

Required Associated Types§

Source

type Body: Body + Send + 'static

The body type used by this cache manager

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, cache_key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<(Response<Self::Body>, CachePolicy)>>> + Send + 'async_trait>>
where <Self::Body as Body>::Data: Send, <Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Attempts to pull a cached response and related policy from cache with streaming body.

Source

fn put<'life0, 'async_trait, B>( &'life0 self, cache_key: String, response: Response<B>, policy: CachePolicy, request_url: Url, ) -> Pin<Box<dyn Future<Output = Result<Response<Self::Body>>> + Send + 'async_trait>>
where B: Body + Send + 'static + 'async_trait, B::Data: Send, B::Error: Into<StreamingError>, <Self::Body as Body>::Data: Send, <Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static, Self: 'async_trait, 'life0: 'async_trait,

Attempts to cache a response with a streaming body and related policy.

Source

fn convert_body<'life0, 'async_trait, B>( &'life0 self, response: Response<B>, ) -> Pin<Box<dyn Future<Output = Result<Response<Self::Body>>> + Send + 'async_trait>>
where B: Body + Send + 'static + 'async_trait, B::Data: Send, B::Error: Into<StreamingError>, <Self::Body as Body>::Data: Send, <Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static, Self: 'async_trait, 'life0: 'async_trait,

Converts a generic body to the manager’s body type for non-cacheable responses. This is called when a response should not be cached but still needs to be returned with the correct body type.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, cache_key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Attempts to remove a record from cache.

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§