Skip to main content

RepositoryAccessor

Trait RepositoryAccessor 

Source
pub trait RepositoryAccessor {
    // Required methods
    fn registry(&self) -> &Git2DB;
    fn repo_id(&self) -> &RepoId;

    // Provided methods
    fn repo_path(&self) -> Git2DBResult<PathBuf> { ... }
    fn open_repo(
        &self,
    ) -> impl Future<Output = Git2DBResult<Repository>> + Send + '_
       where Self: Sync { ... }
}
Expand description

Trait for types that need to access repositories through the registry

This trait provides default implementations for common operations like getting the repository path and opening the repository.

Required Methods§

Source

fn registry(&self) -> &Git2DB

Get the registry reference

Source

fn repo_id(&self) -> &RepoId

Get the repository ID

Provided Methods§

Source

fn repo_path(&self) -> Git2DBResult<PathBuf>

Get the repository worktree path

Source

fn open_repo( &self, ) -> impl Future<Output = Git2DBResult<Repository>> + Send + '_
where Self: Sync,

Open the git repository (async, uses spawn_blocking)

Opens a fresh Repository instance. Note that git2::Repository is not thread-safe, so each call creates a new instance.

This method uses spawn_blocking to avoid blocking the async executor, following the pattern from CLAUDE.md for libgit2 operations.

Returns an impl Future + Send to explicitly ensure Send-safety.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§