pub trait CacheStorage:
Send
+ Sync
+ 'static {
// Required methods
fn get<B: HttpBody>(
&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 put_with_body<B: HttpBody>(
&self,
key: &str,
parts: &Parts,
policy: &CachePolicy,
body: B,
) -> impl Future<Output = Result<(Body<B>, String)>> + 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: HttpBody>(
&self,
key: &str,
) -> impl Future<Output = Result<Option<StoredResponse<B>>>> + Send
fn get<B: HttpBody>( &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 put_with_body<B: HttpBody>(
&self,
key: &str,
parts: &Parts,
policy: &CachePolicy,
body: B,
) -> impl Future<Output = Result<(Body<B>, String)>> + Send
fn put_with_body<B: HttpBody>( &self, key: &str, parts: &Parts, policy: &CachePolicy, body: B, ) -> impl Future<Output = Result<(Body<B>, String)>> + Send
Puts a response with supplied body into the storage for the given response key.
Returns the body from the cache along with its digest upon success.
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.