pub trait Cache: DeserializeOwned {
type AcceptStorePoint: BaseStorePoint;
// Provided methods
fn refresh_cache<P: AsRef<Path> + Send>(
base: &Self::AcceptStorePoint,
suffix: P,
client: Client,
url: &str,
) -> impl Future<Output = Result<Self>> + Send { ... }
fn try_cache<P: AsRef<Path> + Send>(
base: &Self::AcceptStorePoint,
suffix: P,
client: Client,
url: &str,
) -> impl Future<Output = Result<Self>> + Send { ... }
fn check_cache<P: AsRef<Path> + Send>(
base: &Self::AcceptStorePoint,
suffix: P,
client: Client,
url: &str,
sha: SHA,
) -> impl Future<Output = Result<Self>> + Send { ... }
fn builder() -> CacheBuilder<Self::AcceptStorePoint, Self>
where Self::AcceptStorePoint: Clone { ... }
}Required Associated Types§
Provided Methods§
fn refresh_cache<P: AsRef<Path> + Send>( base: &Self::AcceptStorePoint, suffix: P, client: Client, url: &str, ) -> impl Future<Output = Result<Self>> + Send
Sourcefn try_cache<P: AsRef<Path> + Send>(
base: &Self::AcceptStorePoint,
suffix: P,
client: Client,
url: &str,
) -> impl Future<Output = Result<Self>> + Send
fn try_cache<P: AsRef<Path> + Send>( base: &Self::AcceptStorePoint, suffix: P, client: Client, url: &str, ) -> impl Future<Output = Result<Self>> + Send
this will check file exist or not.
if the file exist, it will return the data from disk.
if the file not exist, it will fetch the data from the source and save it to the disk, then return the data.
a dirty way to avoid async trait warning, you should see this as async fn try_cache -> anyhow::Result<Self>;
Sourcefn check_cache<P: AsRef<Path> + Send>(
base: &Self::AcceptStorePoint,
suffix: P,
client: Client,
url: &str,
sha: SHA,
) -> impl Future<Output = Result<Self>> + Send
fn check_cache<P: AsRef<Path> + Send>( base: &Self::AcceptStorePoint, suffix: P, client: Client, url: &str, sha: SHA, ) -> impl Future<Output = Result<Self>> + Send
- the file exist and the sha is valid, return the data from disk.
- the file exist and the sha is invalid, fetch the data from the source and save it to the disk, then return the data.
- the file not exist, fetch the data from the source and save it to the disk, then return the data.
Sourcefn builder() -> CacheBuilder<Self::AcceptStorePoint, Self>where
Self::AcceptStorePoint: Clone,
fn builder() -> CacheBuilder<Self::AcceptStorePoint, Self>where
Self::AcceptStorePoint: Clone,
Return a builder for 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.