pub struct RegistrationBuilder<'a> { /* private fields */ }Expand description
Builder for registering repositories and worktrees
Provides a chainable interface for configuring registration operations. This is the recommended way to register repos, worktrees, and adapters.
§Examples
use git2db::{RepoId, GitRef};
use std::path::PathBuf;
// Register a worktree (adapter)
let adapter_id = RepoId::new();
registry.register(adapter_id)
.name("my-adapter")
.worktree_path(PathBuf::from("/models/working/adapter-uuid"))
.tracking_ref(GitRef::Branch("adapter/uuid".to_owned()))
.metadata("type", "adapter")
.metadata("base_model", "llama-uuid")
.exec()
.await?;
// Register a cloned repository
let model_id = RepoId::new();
registry.register(model_id)
.name("llama-3")
.url("https://github.com/meta/llama")
.worktree_path(PathBuf::from("/models/llama-uuid"))
.remote("origin", "https://github.com/meta/llama")
.exec()
.await?;Implementations§
Source§impl<'a> RegistrationBuilder<'a>
impl<'a> RegistrationBuilder<'a>
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Set the repository name
This is a human-friendly name for looking up the repository.
Sourcepub fn url(self, url: impl Into<String>) -> Self
pub fn url(self, url: impl Into<String>) -> Self
Set the remote URL
For local worktrees/adapters, this can be an empty string.
Sourcepub fn worktree_path(self, path: impl Into<PathBuf>) -> Self
pub fn worktree_path(self, path: impl Into<PathBuf>) -> Self
Set the worktree path
This is the actual filesystem location of the repository or worktree. REQUIRED - must be called before exec().
The path must exist before registration.
Sourcepub fn tracking_ref(self, git_ref: GitRef) -> Self
pub fn tracking_ref(self, git_ref: GitRef) -> Self
Set the tracking ref
Specifies which branch, tag, or commit this repository tracks.
Defaults to GitRef::DefaultBranch if not specified.
Sourcepub fn remote(self, name: impl Into<String>, url: impl Into<String>) -> Self
pub fn remote(self, name: impl Into<String>, url: impl Into<String>) -> Self
Add a remote
Can be called multiple times to add multiple remotes.
Sourcepub fn metadata(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn metadata(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add metadata key-value pair
Metadata is stored in the registry and can be used for domain-specific information like adapter type, base model ID, etc.
Can be called multiple times to add multiple metadata entries.
Sourcepub async fn exec(self) -> Git2DBResult<()>
pub async fn exec(self) -> Git2DBResult<()>
Execute the registration
Validates configuration and registers the repository/worktree in the registry.
§Errors
Returns an error if:
worktree_pathwas not specified- The worktree path does not exist
- The repository ID is already registered
- Git operations fail (submodule creation, commit, etc.)
Auto Trait Implementations§
impl<'a> Freeze for RegistrationBuilder<'a>
impl<'a> !RefUnwindSafe for RegistrationBuilder<'a>
impl<'a> Send for RegistrationBuilder<'a>
impl<'a> Sync for RegistrationBuilder<'a>
impl<'a> Unpin for RegistrationBuilder<'a>
impl<'a> UnsafeUnpin for RegistrationBuilder<'a>
impl<'a> !UnwindSafe for RegistrationBuilder<'a>
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more