cloud_terrastodon_command/
cache_invalidatable.rs1use crate::CacheKey;
2use crate::HasCacheKey;
3use async_trait::async_trait;
4
5#[async_trait]
6pub trait CacheInvalidatable {
7 async fn invalidate(&self) -> eyre::Result<()>;
8}
9
10#[async_trait]
11impl CacheInvalidatable for &CacheKey {
12 async fn invalidate(&self) -> eyre::Result<()> {
13 CacheKey::invalidate(self).await
14 }
15}
16
17#[async_trait]
18impl<T> CacheInvalidatable for T
19where
20 T: HasCacheKey + Sync,
21{
22 async fn invalidate(&self) -> eyre::Result<()> {
23 let cache_key = self.cache_key();
24 cache_key.invalidate().await
25 }
26}
27
28pub trait CacheInvalidatableIntoFuture: IntoFuture + Sized {
29 type WithInvalidation: IntoFuture<Output = Self::Output>;
30 fn with_invalidation(self, invalidate_cache: bool) -> Self::WithInvalidation;
32}