use crate::commit::{Commit, CommitId};
use crate::error::Result;
use async_trait::async_trait;
#[async_trait]
pub trait CommitStore: Send + Sync {
async fn put(&self, commit: Commit) -> Result<CommitId>;
async fn get(&self, id: &CommitId) -> Result<Option<Commit>>;
async fn contains(&self, id: &CommitId) -> Result<bool>;
async fn children(&self, id: &CommitId) -> Result<Vec<CommitId>>;
async fn len(&self) -> Result<usize>;
async fn is_empty(&self) -> Result<bool> {
Ok(self.len().await? == 0)
}
async fn all_ids(&self) -> Result<Vec<CommitId>>;
async fn remove_many(&self, ids: &[CommitId]) -> Result<()>;
}
#[async_trait]
pub trait RefStore: Send + Sync {
async fn get_branch(&self, name: &str) -> Result<Option<CommitId>>;
async fn set_branch(&self, name: &str, commit_id: CommitId) -> Result<()>;
async fn delete_branch(&self, name: &str) -> Result<()>;
async fn list_branches(&self) -> Result<Vec<(String, CommitId)>>;
}