use std::hash::Hash;
use aa_core::storage::{AgentId, PolicyDocument, PolicyStore, Result};
use async_trait::async_trait;
#[async_trait]
pub trait CacheSource: Send + Sync {
type Key: Eq + Hash + Clone + Send + Sync;
type Value: Clone + Send + Sync;
async fn load(&self, key: &Self::Key) -> Result<Self::Value>;
}
#[async_trait]
impl<P: PolicyStore> CacheSource for P {
type Key = AgentId;
type Value = PolicyDocument;
async fn load(&self, key: &AgentId) -> Result<PolicyDocument> {
self.get_policy(key).await
}
}