pub trait CacheDb:
Send
+ Sync
+ 'static {
// Required methods
fn clone_boxed(&self) -> Box<dyn CacheDb>;
fn policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<CachePolicy>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set_policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn body<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
body: Body,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn purge<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn prune<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Represents a download cache in a Client
.
Cache implementers must store a CachePolicy
and Body
for a given CacheKey
.
Required Methods§
sourcefn clone_boxed(&self) -> Box<dyn CacheDb>
fn clone_boxed(&self) -> Box<dyn CacheDb>
Dynamic clone.
sourcefn policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<CachePolicy>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<CachePolicy>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves the cache-policy for the given key
.
sourcefn set_policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Replaces the cache-policy for the given key
.
Returns false
if the entry does not exist.
sourcefn body<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn body<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read/clone the cached body for the given key
.
sourcefn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
body: Body,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
body: Body,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Caches the policy
and body
for the given key
.
The body
is fully downloaded and stored into the cache, this method can await for the full download
before returning or return immediately with a body that updates as data is cached.
In case of error the cache entry is removed, the returned body may continue downloading data if possible.
In case of a cache entry creation error the input body
may be returned if it was not lost in the error.
sourcefn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove cached policy and body for the given key
.