pub trait CacheStorage:
Send
+ Sync
+ 'static {
// Required methods
fn get<B: Body + Send>(
&self,
key: &str,
) -> impl Future<Output = Result<Option<StoredResponse<B>>>> + Send;
fn put(
&self,
key: &str,
parts: &Parts,
policy: &CachePolicy,
digest: &str,
) -> impl Future<Output = Result<()>> + Send;
fn store<B: Body + Send>(
&self,
key: String,
parts: Parts,
body: B,
policy: CachePolicy,
) -> impl Future<Output = Result<Response<CacheBody<B>>>> + Send;
fn delete(&self, key: &str) -> impl Future<Output = Result<()>> + Send;
fn body_path(&self, digest: &str) -> PathBuf;
}Expand description
A trait implemented on cache storage.
Cache keys are strings of hexadecimal characters.
Required Methods§
Sourcefn get<B: Body + Send>(
&self,
key: &str,
) -> impl Future<Output = Result<Option<StoredResponse<B>>>> + Send
fn get<B: Body + Send>( &self, key: &str, ) -> impl Future<Output = Result<Option<StoredResponse<B>>>> + Send
Gets a previously stored response for the given response key.
Returns Ok(None) if a response does not exist in the storage for the
given response key.
Sourcefn put(
&self,
key: &str,
parts: &Parts,
policy: &CachePolicy,
digest: &str,
) -> impl Future<Output = Result<()>> + Send
fn put( &self, key: &str, parts: &Parts, policy: &CachePolicy, digest: &str, ) -> impl Future<Output = Result<()>> + Send
Puts a response with an existing content digest into the storage for the given response key.
The provided content digest must come from a previous call to
CacheStorage::get.
Sourcefn store<B: Body + Send>(
&self,
key: String,
parts: Parts,
body: B,
policy: CachePolicy,
) -> impl Future<Output = Result<Response<CacheBody<B>>>> + Send
fn store<B: Body + Send>( &self, key: String, parts: Parts, body: B, policy: CachePolicy, ) -> impl Future<Output = Result<Response<CacheBody<B>>>> + Send
Stores a new response body in the cache.
Returns a response with a body streaming to the cache.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".