use async_trait::async_trait;
use std::fmt::Debug;
use std::hash::Hash;
#[async_trait]
pub trait CacheLoader: Debug + Send + Sync + 'static {
type K: Debug + Hash + Send + 'static;
type V: Debug + Send + 'static;
type Extra: Debug + Send + 'static;
async fn load(&self, k: Self::K, extra: Self::Extra) -> Self::V;
}
#[async_trait]
impl<K, V, Extra> CacheLoader for Box<dyn CacheLoader<K = K, V = V, Extra = Extra>>
where
K: Debug + Hash + Send + 'static,
V: Debug + Send + 'static,
Extra: Debug + Send + 'static,
{
type K = K;
type V = V;
type Extra = Extra;
async fn load(&self, k: Self::K, extra: Self::Extra) -> Self::V {
self.as_ref().load(k, extra).await
}
}