use rskit_errors::AppResult;
use crate::options::{BlameOptions, DescribeOptions, GrepOptions, LogOptions};
use crate::types::{
BlameLine, Commit, DiffEntry, DiffStats, GrepMatch, IndexEntry, Oid, StatusEntry, TreeEntry,
TreeHash,
};
pub trait Differ {
fn diff(&self, from: &str, to: &str) -> AppResult<Vec<DiffEntry>>;
fn diff_stats(&self, from: &str, to: &str) -> AppResult<DiffStats>;
fn status(&self) -> AppResult<Vec<StatusEntry>>;
}
pub trait IgnoreReader {
fn is_ignored(&self, path: &str) -> AppResult<bool>;
}
pub trait IndexReader {
fn index_entry(&self, path: &str) -> AppResult<Option<IndexEntry>>;
}
pub trait TreeReader {
fn tree_hash(&self, revision: &str, path: &str) -> AppResult<TreeHash>;
fn file_at(&self, revision: &str, path: &str) -> AppResult<Vec<u8>>;
fn list_entries(&self, revision: &str, path: &str) -> AppResult<Vec<TreeEntry>>;
}
pub trait LogReader {
fn log(&self, opts: Option<&LogOptions>) -> AppResult<Vec<Commit>>;
fn merge_base(&self, a: &str, b: &str) -> AppResult<Oid>;
fn is_ancestor(&self, ancestor: &str, descendant: &str) -> AppResult<bool>;
}
pub trait Blamer {
fn blame(
&self,
revision: &str,
path: &str,
opts: Option<&BlameOptions>,
) -> AppResult<Vec<BlameLine>>;
}
pub trait Inspector {
fn describe(&self, opts: Option<&DescribeOptions>) -> AppResult<String>;
fn rev_parse(&self, revision: &str) -> AppResult<Oid>;
fn grep(
&self,
pattern: &str,
revision: &str,
opts: Option<&GrepOptions>,
) -> AppResult<Vec<GrepMatch>>;
fn show(&self, object: &str) -> AppResult<Vec<u8>>;
}