pub trait VcsBackend: Send + Sync {
Show 19 methods
// Required methods
fn init(&self, path: &Path) -> Result<(), NapError>;
fn commit(
&self,
path: &Path,
message: &str,
author: &str,
) -> Result<String, NapError>;
fn read_file_at_ref(
&self,
repo_path: &Path,
file_path: &str,
reference: Option<&str>,
) -> Result<String, NapError>;
fn log(
&self,
path: &Path,
file: Option<&str>,
limit: usize,
) -> Result<Vec<CommitInfo>, NapError>;
fn create_branch(&self, path: &Path, name: &str) -> Result<(), NapError>;
fn switch_branch(&self, path: &Path, name: &str) -> Result<(), NapError>;
fn current_branch(&self, path: &Path) -> Result<String, NapError>;
fn head_hash(&self, path: &Path) -> Result<String, NapError>;
fn list_branches(&self, path: &Path) -> Result<Vec<String>, NapError>;
fn add_remote(
&self,
path: &Path,
name: &str,
url: &str,
) -> Result<(), NapError>;
fn remove_remote(&self, path: &Path, name: &str) -> Result<(), NapError>;
fn list_remotes(
&self,
path: &Path,
) -> Result<Vec<(String, String)>, NapError>;
fn push(
&self,
path: &Path,
remote: Option<&str>,
branch: Option<&str>,
) -> Result<(), NapError>;
fn pull(
&self,
path: &Path,
remote: Option<&str>,
branch: Option<&str>,
) -> Result<(), NapError>;
// Provided methods
fn revert(
&self,
_path: &Path,
_commit_hash: &str,
) -> Result<String, NapError> { ... }
fn resolve_branch_head(
&self,
path: &Path,
branch: &str,
) -> Result<String, NapError> { ... }
fn remote_url_base(&self) -> Result<String, NapError> { ... }
fn file_metadata_at_ref(
&self,
_repo_path: &Path,
_file_path: &str,
_reference: &str,
) -> Result<Option<BTreeMap<String, String>>, NapError> { ... }
fn read_provenance_blob(
&self,
_repo_path: &Path,
_address: &str,
) -> Result<String, NapError> { ... }
}Expand description
Low-level abstraction over a version control system.
Most consumer code should use [RepoService] instead — it adds
permissions, context-document management, and a
workspace-lifecycle API on top of this trait.
Required Methods§
Sourcefn init(&self, path: &Path) -> Result<(), NapError>
fn init(&self, path: &Path) -> Result<(), NapError>
Initialize a new repository at the given path.
Sourcefn commit(
&self,
path: &Path,
message: &str,
author: &str,
) -> Result<String, NapError>
fn commit( &self, path: &Path, message: &str, author: &str, ) -> Result<String, NapError>
Stage all files and create a commit.
Sourcefn read_file_at_ref(
&self,
repo_path: &Path,
file_path: &str,
reference: Option<&str>,
) -> Result<String, NapError>
fn read_file_at_ref( &self, repo_path: &Path, file_path: &str, reference: Option<&str>, ) -> Result<String, NapError>
Read a file’s content at a specific ref (branch, tag, or commit hash).
If reference is None, reads from the current working tree.
Sourcefn log(
&self,
path: &Path,
file: Option<&str>,
limit: usize,
) -> Result<Vec<CommitInfo>, NapError>
fn log( &self, path: &Path, file: Option<&str>, limit: usize, ) -> Result<Vec<CommitInfo>, NapError>
Get the commit log for the repository, optionally filtered to a specific file.
Sourcefn list_remotes(&self, path: &Path) -> Result<Vec<(String, String)>, NapError>
fn list_remotes(&self, path: &Path) -> Result<Vec<(String, String)>, NapError>
List remotes as (name, url) pairs.
Provided Methods§
Sourcefn revert(&self, _path: &Path, _commit_hash: &str) -> Result<String, NapError>
fn revert(&self, _path: &Path, _commit_hash: &str) -> Result<String, NapError>
Revert a commit by creating a new commit that undoes it.
Sourcefn resolve_branch_head(
&self,
path: &Path,
branch: &str,
) -> Result<String, NapError>
fn resolve_branch_head( &self, path: &Path, branch: &str, ) -> Result<String, NapError>
Resolve the most recent commit hash on a given branch.
The default implementation returns an error — backends that support branch-based resolution must override this.
Sourcefn remote_url_base(&self) -> Result<String, NapError>
fn remote_url_base(&self) -> Result<String, NapError>
Get the remote URL base for constructing repository URLs.
The default implementation returns an error — backends that support remote URL construction must override this.
Sourcefn file_metadata_at_ref(
&self,
_repo_path: &Path,
_file_path: &str,
_reference: &str,
) -> Result<Option<BTreeMap<String, String>>, NapError>
fn file_metadata_at_ref( &self, _repo_path: &Path, _file_path: &str, _reference: &str, ) -> Result<Option<BTreeMap<String, String>>, NapError>
Read file metadata attached to a path at a specific revision.
Lore file metadata is addressed by working-tree path plus revision, not by the raw content hash of the file bytes.
Sourcefn read_provenance_blob(
&self,
_repo_path: &Path,
_address: &str,
) -> Result<String, NapError>
fn read_provenance_blob( &self, _repo_path: &Path, _address: &str, ) -> Result<String, NapError>
Read a readable immutable provenance artifact by Lore address/hash.
Production Lore verifies immutable fragment addressing internally. NAP uses this only for known readable provenance artifacts, never arbitrary binary assets.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".