pub struct Repository {
pub root: PathBuf,
pub universe: String,
/* private fields */
}Expand description
A NAP universe repository.
Fields§
§root: PathBufFilesystem path to the repository root.
universe: StringThe universe name (derived from directory name).
Implementations§
Source§impl Repository
impl Repository
Sourcepub fn open(path: &Path, vcs: Box<dyn VcsBackend>) -> Result<Self, NapError>
pub fn open(path: &Path, vcs: Box<dyn VcsBackend>) -> Result<Self, NapError>
Open an existing NAP repository at the given path.
Sourcepub fn init(
path: &Path,
universe: &str,
vcs: Box<dyn VcsBackend>,
) -> Result<Self, NapError>
pub fn init( path: &Path, universe: &str, vcs: Box<dyn VcsBackend>, ) -> Result<Self, NapError>
Initialize a new NAP repository.
Sourcepub fn manifest_path(&self, entity_type: EntityType, entity_id: &str) -> PathBuf
pub fn manifest_path(&self, entity_type: EntityType, entity_id: &str) -> PathBuf
Get the full filesystem path to an entity’s manifest file.
Sourcepub fn read_manifest(
&self,
entity_type: EntityType,
entity_id: &str,
) -> Result<Manifest, NapError>
pub fn read_manifest( &self, entity_type: EntityType, entity_id: &str, ) -> Result<Manifest, NapError>
Read a manifest from the repository.
Sourcepub fn read_manifest_at_ref(
&self,
entity_type: EntityType,
entity_id: &str,
reference: &str,
) -> Result<Manifest, NapError>
pub fn read_manifest_at_ref( &self, entity_type: EntityType, entity_id: &str, reference: &str, ) -> Result<Manifest, NapError>
Read a manifest at a specific VCS ref (commit, branch, tag).
Sourcepub fn write_manifest(&self, manifest: &Manifest) -> Result<PathBuf, NapError>
pub fn write_manifest(&self, manifest: &Manifest) -> Result<PathBuf, NapError>
Write a manifest to the repository (does NOT commit).
Sourcepub fn create_entity(
&self,
entity_type: EntityType,
entity_id: &str,
name: &str,
author: &str,
) -> Result<(Manifest, String), NapError>
pub fn create_entity( &self, entity_type: EntityType, entity_id: &str, name: &str, author: &str, ) -> Result<(Manifest, String), NapError>
Create a new entity manifest and commit it.
Sourcepub fn commit_manifest(
&self,
manifest: &mut Manifest,
message: &str,
author: &str,
changes: Vec<Change>,
) -> Result<Commit, NapError>
pub fn commit_manifest( &self, manifest: &mut Manifest, message: &str, author: &str, changes: Vec<Change>, ) -> Result<Commit, NapError>
Update an existing manifest and commit the changes.
Sourcepub fn history(
&self,
entity_type: EntityType,
entity_id: &str,
limit: usize,
) -> Result<Vec<CommitInfo>, NapError>
pub fn history( &self, entity_type: EntityType, entity_id: &str, limit: usize, ) -> Result<Vec<CommitInfo>, NapError>
Get the commit history for a specific entity.
Sourcepub fn list_entities(
&self,
entity_type: EntityType,
) -> Result<Vec<String>, NapError>
pub fn list_entities( &self, entity_type: EntityType, ) -> Result<Vec<String>, NapError>
List all entity IDs of a given type in the repository.
Sourcepub fn delete_entity(
&self,
entity_type: EntityType,
entity_id: &str,
author: &str,
) -> Result<String, NapError>
pub fn delete_entity( &self, entity_type: EntityType, entity_id: &str, author: &str, ) -> Result<String, NapError>
Delete an entity manifest and commit the deletion.
Sourcepub fn create_branch(&self, name: &str) -> Result<(), NapError>
pub fn create_branch(&self, name: &str) -> Result<(), NapError>
Create a branch in the underlying VCS.
List tags.
Sourcepub fn revert_commit(
&self,
commit_hash: &str,
author: &str,
) -> Result<String, NapError>
pub fn revert_commit( &self, commit_hash: &str, author: &str, ) -> Result<String, NapError>
Revert a commit by creating a new VCS commit that undoes the specified one.
The revert is a universe-level operation (not entity-scoped) — a single Git commit can touch multiple files across multiple entity types. After reverting, working-tree files are restored to their pre-commit content and a new revert commit is created in VCS history.
Sourcepub fn resolve_branch_head(&self, branch: &str) -> Result<String, NapError>
pub fn resolve_branch_head(&self, branch: &str) -> Result<String, NapError>
Resolve the most recent commit hash on a given branch.
Sourcepub fn add_remote(&self, name: &str, url: &str) -> Result<(), NapError>
pub fn add_remote(&self, name: &str, url: &str) -> Result<(), NapError>
Add a remote to the repository.
Sourcepub fn remove_remote(&self, name: &str) -> Result<(), NapError>
pub fn remove_remote(&self, name: &str) -> Result<(), NapError>
Remove a remote from the repository.
Sourcepub fn list_remotes(&self) -> Result<Vec<(String, String)>, NapError>
pub fn list_remotes(&self) -> Result<Vec<(String, String)>, NapError>
List remotes as (name, url) pairs.
Sourcepub fn push(
&self,
remote: Option<&str>,
branch: Option<&str>,
) -> Result<(), NapError>
pub fn push( &self, remote: Option<&str>, branch: Option<&str>, ) -> Result<(), NapError>
Push the current branch to a remote.
Sourcepub fn pull(
&self,
remote: Option<&str>,
branch: Option<&str>,
) -> Result<(), NapError>
pub fn pull( &self, remote: Option<&str>, branch: Option<&str>, ) -> Result<(), NapError>
Pull the current branch from a remote.
Sourcepub fn vcs(&self) -> &dyn VcsBackend
pub fn vcs(&self) -> &dyn VcsBackend
Access the VCS backend (for the resolver to read files at specific refs).
Auto Trait Implementations§
impl !RefUnwindSafe for Repository
impl !UnwindSafe for Repository
impl Freeze for Repository
impl Send for Repository
impl Sync for Repository
impl Unpin for Repository
impl UnsafeUnpin for Repository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request