pub struct Repository { /* private fields */ }Expand description
An isolated repository handle. Only read operations are exposed.
Configuration is strict and repository-local. RAF enables only native index, revision and hash features; its read paths never invoke helpers, transports, hooks or filters. Missing objects fail locally. Native decoding internals are outside Source’s portable meters; callers retain explicit bounds on decoded objects and acquired results.
Implementations§
Source§impl Repository
impl Repository
Sourcepub fn discover(directory: impl AsRef<Path>) -> Result<Option<Self>, Error>
pub fn discover(directory: impl AsRef<Path>) -> Result<Option<Self>, Error>
Discover a repository above directory, without environment selectors.
§Errors
Fails on inaccessible paths, malformed repositories or configuration.
None means discovery reached a boundary without finding a repository.
Sourcepub fn open(directory: impl AsRef<Path>) -> Result<Self, Error>
pub fn open(directory: impl AsRef<Path>) -> Result<Self, Error>
Open the repository containing the exact selected directory.
§Errors
Fails when discovery has no repository or encounters invalid data.
Sourcepub fn open_with_allocation_limit(
directory: impl AsRef<Path>,
allocation_limit: usize,
) -> Result<Self, Error>
pub fn open_with_allocation_limit( directory: impl AsRef<Path>, allocation_limit: usize, ) -> Result<Self, Error>
Open with an explicit native decoder per-allocation grant.
This bounds loose/packed inflation and index-derived allocations, not aggregate model memory or traversal work. Source’s portable meters still govern acquired buffers and model processing separately.
§Errors
Refuses zero/unrepresentable grants and all failures of Self::open.
Sourcepub fn open_with_index(
directory: impl AsRef<Path>,
index: Option<&Path>,
) -> Result<Self, Error>
pub fn open_with_index( directory: impl AsRef<Path>, index: Option<&Path>, ) -> Result<Self, Error>
Open with one explicitly selected index; no process environment is changed.
§Errors
As Self::open. Relative indexes are anchored at the selected directory.
Sourcepub fn common_dir(&self) -> &Path
pub fn common_dir(&self) -> &Path
The shared Git directory, including for linked checkouts.
Sourcepub fn main_work_dir(&self) -> Result<Option<PathBuf>, Error>
pub fn main_work_dir(&self) -> Result<Option<PathBuf>, Error>
The canonical checkout root of the main worktree, from a linked checkout or the main checkout alike; absent when the main repository is bare. The main repository is opened with the same isolated, read-only options as this handle.
§Errors
Fails when the main repository cannot be opened or its checkout root cannot be resolved.
Sourcepub fn index_path(&self) -> PathBuf
pub fn index_path(&self) -> PathBuf
The explicitly selected or ordinary private index path.
Sourcepub fn resolve_commit(&self, reference: &str) -> Result<String, Error>
pub fn resolve_commit(&self, reference: &str) -> Result<String, Error>
Resolve HEAD or a full reference to an existing commit.
§Errors
Refuses missing, malformed or non-commit objects and unsupported selectors.
Sourcepub fn default_branch_ref(&self) -> Result<String, Error>
pub fn default_branch_ref(&self) -> Result<String, Error>
Return origin’s symbolic default reference, without guessing a branch.
§Errors
Refuses absent, direct or malformed origin HEAD references.
Sourcepub fn merge_base(&self, one: &str, two: &str) -> Result<Option<String>, Error>
pub fn merge_base(&self, one: &str, two: &str) -> Result<Option<String>, Error>
Find a best common ancestor, or None for unrelated histories.
§Errors
Refuses invalid identifiers, missing objects and traversal failures.
Sourcepub fn tracked_paths(&self, max: usize) -> Result<Option<Vec<String>>, Error>
pub fn tracked_paths(&self, max: usize) -> Result<Option<Vec<String>>, Error>
Read existing index paths below the selected directory.
§Errors
Refuses oversized/malformed indexes, invalid UTF-8 and noncanonical paths. Metadata inspection uses a verified disk handle rooted at the index parent; final symlinks outside that root refuse. Native decoding reopens by name, so this is not an atomic observation against a concurrent directory swap.
Sourcepub fn commit(&self, id: &str) -> Result<Commit, Error>
pub fn commit(&self, id: &str) -> Result<Commit, Error>
Read bounded immutable commit metadata. Messages must be UTF-8; absent encoding headers and the UTF-8/UTF8 encoding names are supported without transcoding.
§Errors
Refuses missing, corrupt, oversized or incorrectly typed objects.
Sourcepub fn is_shallow(&self) -> Result<bool, Error>
pub fn is_shallow(&self) -> Result<bool, Error>
Whether the repository declares a shallow history boundary.
§Errors
Refuses unreadable or malformed shallow metadata.
Sourcepub fn relative_history_paths(&self) -> Result<bool, Error>
pub fn relative_history_paths(&self) -> Result<bool, Error>
Whether repository-local history display uses selected-directory paths.
§Errors
Refuses a malformed boolean rather than selecting a fallback format.
Sourcepub fn tree(&self, commit: &str, max: usize) -> Result<Vec<Entry>, Error>
pub fn tree(&self, commit: &str, max: usize) -> Result<Vec<Entry>, Error>
List all committed directories and leaves under an exact commit.
§Errors
Refuses malformed names/modes, missing objects and cumulative byte exhaustion.
Sourcepub fn blob(&self, id: &str, max: usize) -> Result<Vec<u8>, Error>
pub fn blob(&self, id: &str, max: usize) -> Result<Vec<u8>, Error>
Read an admitted blob by exact identifier, without filters or checkout access.
§Errors
Refuses absent, corrupt, oversized or non-blob objects.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Repository
impl !RefUnwindSafe for Repository
impl !Send for Repository
impl !Sync for Repository
impl !UnwindSafe for Repository
impl Forget for Repository
impl Move 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
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