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 store<B: HttpBody>(
&self,
key: String,
parts: Parts,
body: B,
policy: CachePolicy,
) -> impl Future<Output = Result<Response<Body<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: 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 store<B: HttpBody>(
&self,
key: String,
parts: Parts,
body: B,
policy: CachePolicy,
) -> impl Future<Output = Result<Response<Body<B>>>> + Send
fn store<B: HttpBody>( &self, key: String, parts: Parts, body: B, policy: CachePolicy, ) -> impl Future<Output = Result<Response<Body<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", so this trait is not object safe.