Skip to main content

Repository

Struct Repository 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn directory(&self) -> &Path

The originally selected canonical directory.

Source

pub fn git_dir(&self) -> &Path

The selected checkout’s private Git directory.

Source

pub fn common_dir(&self) -> &Path

The shared Git directory, including for linked checkouts.

Source

pub fn work_dir(&self) -> Option<&Path>

The checkout root, absent for bare repositories.

Source

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.

Source

pub fn index_path(&self) -> PathBuf

The explicitly selected or ordinary private index path.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_shallow(&self) -> Result<bool, Error>

Whether the repository declares a shallow history boundary.

§Errors

Refuses unreadable or malformed shallow metadata.

Source

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.

Source

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.

Source

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.

Source

pub fn entry_at(&self, commit: &str, path: &str) -> Result<Option<Entry>, Error>

Look up a path in an exact committed tree without following symbolic links.

§Errors

Refuses invalid paths, corrupt/missing objects and intermediate non-directories.

Source

pub fn ancestors(&self, max: usize) -> Result<Vec<Commit>, Error>

Walk HEAD ancestors in newest-committer-first order with bounded metadata.

§Errors

Refuses missing/corrupt commits or a traversal exceeding max bytes.

Trait Implementations§

Source§

impl Debug for Repository

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.