use crate::types::{ActionId, BuildEvent};
use async_trait::async_trait;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum CacheError {
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("backend: {0}")]
Backend(String),
}
pub type Result<T> = std::result::Result<T, CacheError>;
#[async_trait]
pub trait Cache: Send + Sync {
async fn last_build(&self, id: &ActionId) -> Option<BuildEvent>;
async fn record(&mut self, event: BuildEvent) -> Result<()>;
async fn record_batch(&mut self, events: Vec<BuildEvent>) -> Result<()> {
for event in events {
self.record(event).await?;
}
Ok(())
}
}