pub struct RepoService {
pub permission_gate: PermissionGate,
pub context_docs: ContextDocsManager,
/* private fields */
}Expand description
High-level interface for all VCS operations in NAP.
§Thread safety
RepoService is Send + Sync and safe to share across threads.
Internal state (e.g., the permission gate cache, context-doc graph)
uses interior mutability.
Fields§
§permission_gate: PermissionGatePermission gate.
context_docs: ContextDocsManagerContext-document manager.
Implementations§
Source§impl RepoService
impl RepoService
Sourcepub fn new(
backend: Box<dyn VcsBackend>,
workspace_root: &Path,
) -> Result<Self, NapError>
pub fn new( backend: Box<dyn VcsBackend>, workspace_root: &Path, ) -> Result<Self, NapError>
Create a new RepoService with the given backend and workspace path.
The permission gate is loaded from context/nap-gate.toml if it
exists, otherwise a permissive gate is used. Use
RepoService::with_gate for custom gate behaviour.
Sourcepub fn with_gate(
backend: Box<dyn VcsBackend>,
workspace_root: &Path,
permission_gate: PermissionGate,
) -> Self
pub fn with_gate( backend: Box<dyn VcsBackend>, workspace_root: &Path, permission_gate: PermissionGate, ) -> Self
Create a RepoService with an explicit permission gate.
Sourcepub fn from_env(workspace_root: &Path) -> Result<Self, NapError>
pub fn from_env(workspace_root: &Path) -> Result<Self, NapError>
Create a RepoService from environment variables (for the common
local-dev case).
Sourcepub fn backend(&self) -> &dyn VcsBackend
pub fn backend(&self) -> &dyn VcsBackend
The underlying VCS backend (for advanced use).
Sourcepub fn workspace_root(&self) -> &Path
pub fn workspace_root(&self) -> &Path
Workspace root path.
Sourcepub fn create_repository(
&self,
workspace_id: &str,
repo_id: &str,
_opts: RepoOptions,
) -> Result<Repository, NapError>
pub fn create_repository( &self, workspace_id: &str, repo_id: &str, _opts: RepoOptions, ) -> Result<Repository, NapError>
Create a repository on the lore server and clone it locally.
This is the primary way to bootstrap a NAP workspace.
Sourcepub fn open_workspace(&self) -> Result<Workspace, NapError>
pub fn open_workspace(&self) -> Result<Workspace, NapError>
Open an existing local workspace (assumes lore clone already
happened, or the workspace directory already exists).
Sourcepub fn write_file(
&self,
path: &str,
content: &str,
principal: &str,
) -> Result<(), NapError>
pub fn write_file( &self, path: &str, content: &str, principal: &str, ) -> Result<(), NapError>
Write a file, checking permissions first.
Sourcepub fn read_file(&self, path: &str, principal: &str) -> Result<String, NapError>
pub fn read_file(&self, path: &str, principal: &str) -> Result<String, NapError>
Read a file, checking permissions first.
Sourcepub fn commit(&self, message: &str, author: &str) -> Result<String, NapError>
pub fn commit(&self, message: &str, author: &str) -> Result<String, NapError>
Commit staged changes.
Sourcepub fn log(
&self,
file: Option<&str>,
limit: usize,
) -> Result<Vec<CommitInfo>, NapError>
pub fn log( &self, file: Option<&str>, limit: usize, ) -> Result<Vec<CommitInfo>, NapError>
Get commit history.
Sourcepub fn current_branch(&self) -> Result<String, NapError>
pub fn current_branch(&self) -> Result<String, NapError>
Get current branch.
List tags.
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 to the lore server.
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 from the lore server.
Sourcepub fn register_context_doc(
&self,
path: &str,
metadata: &[(&str, &str)],
) -> Result<(), NapError>
pub fn register_context_doc( &self, path: &str, metadata: &[(&str, &str)], ) -> Result<(), NapError>
Register a context document. See ContextDocsManager::register.
Sourcepub fn add_context_dep(
&self,
source: &str,
target: &str,
) -> Result<(), NapError>
pub fn add_context_dep( &self, source: &str, target: &str, ) -> Result<(), NapError>
Add a dependency between context documents.
Sourcepub fn all_context_docs(&self) -> Result<Vec<ContextDocument>, NapError>
pub fn all_context_docs(&self) -> Result<Vec<ContextDocument>, NapError>
Get all context documents.
Sourcepub fn start_autopublish(
&self,
config: AutopublishConfig,
) -> Result<AutopublishHandle, NapError>
pub fn start_autopublish( &self, config: AutopublishConfig, ) -> Result<AutopublishHandle, NapError>
Start the autopublish worker.
The worker takes ownership of a new backend instance (created
from env variables) so the shared RepoService backend is not
consumed. If you need a worker with a specific backend, construct
AutopublishWorker directly.
Auto Trait Implementations§
impl !Freeze for RepoService
impl !RefUnwindSafe for RepoService
impl !UnwindSafe for RepoService
impl Send for RepoService
impl Sync for RepoService
impl Unpin for RepoService
impl UnsafeUnpin for RepoService
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