pub struct Repository { /* private fields */ }
Expand description
Represents a Git repository
Implementations§
Source§impl Repository
impl Repository
Sourcepub fn new(path: impl AsRef<Path>) -> Result<Self, RepositoryError>
pub fn new(path: impl AsRef<Path>) -> Result<Self, RepositoryError>
Creates a new Repository instance from a path
§Errors
This function will return an error if:
- The provided path does not contain a .git directory
Sourcepub fn list_pack_files(&self) -> Result<Vec<PathBuf>, RepositoryError>
pub fn list_pack_files(&self) -> Result<Vec<PathBuf>, RepositoryError>
Lists all pack files in the repository
§Errors
This function will return an error if:
- File system operations fail when reading the objects/pack directory
Sourcepub fn list_pack_groups(
&self,
) -> Result<HashMap<String, PackGroup>, RepositoryError>
pub fn list_pack_groups( &self, ) -> Result<HashMap<String, PackGroup>, RepositoryError>
Lists all pack-related files grouped by their base name (without extension)
Returns a map where keys are base names (e.g., “pack-abc123”) and values are structs containing paths to all related files (.pack, .idx, .rev, .mtimes)
§Errors
This function will return an error if:
- File system operations fail when reading the objects/pack directory
Sourcepub fn list_head_refs(&self) -> Result<Vec<PathBuf>, RepositoryError>
pub fn list_head_refs(&self) -> Result<Vec<PathBuf>, RepositoryError>
Lists all head refs (local branches) in the repository
§Errors
This function will return an error if:
- File system operations fail when reading the refs/heads directory
Sourcepub fn list_remote_refs(
&self,
) -> Result<Vec<(String, Vec<PathBuf>)>, RepositoryError>
pub fn list_remote_refs( &self, ) -> Result<Vec<(String, Vec<PathBuf>)>, RepositoryError>
Lists all remote refs grouped by remote name
§Errors
This function will return an error if:
- File system operations fail when reading the refs/remotes directory
Sourcepub fn list_tag_refs(&self) -> Result<Vec<PathBuf>, RepositoryError>
pub fn list_tag_refs(&self) -> Result<Vec<PathBuf>, RepositoryError>
Lists all tag refs in the repository
§Errors
This function will return an error if:
- File system operations fail when reading the refs/tags directory
Sourcepub fn has_stash_ref(&self) -> Result<bool, RepositoryError>
pub fn has_stash_ref(&self) -> Result<bool, RepositoryError>
Checks if stash ref exists
§Errors
This function will return an error if:
- File system operations fail when checking for stash refs
Sourcepub fn list_loose_objects(
&self,
limit: usize,
) -> Result<Vec<PathBuf>, RepositoryError>
pub fn list_loose_objects( &self, limit: usize, ) -> Result<Vec<PathBuf>, RepositoryError>
Lists a sample of loose objects in the repository Limit parameter controls the maximum number of objects to return
§Errors
This function will return an error if:
- File system operations fail when reading loose object directories
Sourcepub fn read_loose_object(
&self,
path: &Path,
) -> Result<LooseObject, RepositoryError>
pub fn read_loose_object( &self, path: &Path, ) -> Result<LooseObject, RepositoryError>
Reads and parses a loose object from the given path
§Errors
This function will return an error if:
- The file cannot be read
- The object cannot be decompressed or parsed
Sourcepub fn read_loose_object_by_hash(
&self,
hash: &str,
) -> Result<LooseObject, RepositoryError>
pub fn read_loose_object_by_hash( &self, hash: &str, ) -> Result<LooseObject, RepositoryError>
Reads and parses a loose object by its hash
§Errors
This function will return an error if:
- The object file cannot be found or read
- The object cannot be decompressed or parsed
Sourcepub fn list_parsed_loose_objects(
&self,
limit: usize,
) -> Result<Vec<LooseObject>, RepositoryError>
pub fn list_parsed_loose_objects( &self, limit: usize, ) -> Result<Vec<LooseObject>, RepositoryError>
List parsed loose objects with a limit
§Errors
This function will return an error if:
- File system operations fail when reading loose object directories
- Objects cannot be parsed or decompressed
Sourcepub fn loose_object_exists(&self, hash: &str) -> bool
pub fn loose_object_exists(&self, hash: &str) -> bool
Check if a loose object exists by its hash
Sourcepub fn get_loose_object_stats(
&self,
) -> Result<LooseObjectStats, RepositoryError>
pub fn get_loose_object_stats( &self, ) -> Result<LooseObjectStats, RepositoryError>
Get statistics about all loose objects in the repository
§Errors
This function will return an error if:
- File system operations fail when reading loose object directories
- Objects cannot be parsed or analyzed
Auto Trait Implementations§
impl Freeze for Repository
impl RefUnwindSafe for Repository
impl Send for Repository
impl Sync for Repository
impl Unpin for Repository
impl UnwindSafe 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