Skip to main content

Graph

Struct Graph 

Source
pub struct Graph { /* private fields */ }
Expand description

A complete commit graph.

The data in the commit graph may come from a monolithic objects/info/commit-graph file, or it may come from one or more objects/info/commit-graphs/graph-*.graph files. These files are generated via git commit-graph write ... commands.

Implementations§

Source§

impl Graph

Access

Source

pub fn commit_at(&self, pos: Position) -> Commit<'_>

Returns the commit at the given position pos.

§Panics

If pos is greater or equal to num_commits().

Source

pub fn object_hash(&self) -> Kind

The kind of hash used in this Graph.

Note that it is always conforming to the hash used in the owning repository.

Source

pub fn commit_by_id(&self, id: impl AsRef<oid>) -> Option<Commit<'_>>

Returns the commit matching the given id.

Source

pub fn id_at(&self, pos: Position) -> &oid

Returns the hash at the given position pos.

§Panics

If pos is greater or equal to num_commits().

Source

pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>>

Iterate over commits in unsorted order.

Source

pub fn iter_ids(&self) -> impl Iterator<Item = &oid>

Iterate over commit IDs in unsorted order.

Source

pub fn lookup(&self, id: impl AsRef<oid>) -> Option<Position>

Translate the given id to its position in the file.

Source

pub fn num_commits(&self) -> u32

Returns the number of commits stored in this file.

Source§

impl Graph

Instantiate a Graph from various sources.

Source

pub fn at( path: &Path, object_hash: Kind, alloc_limit_bytes: Option<usize>, ) -> Result<Self>

Instantiate a commit graph from path which may be a directory containing graph files or the graph file itself.

Chain entries and graph files must use object_hash, typically the repository’s hash kind. Mismatches are reported as corruption.

alloc_limit_bytes bounds a conservative capacity estimate for parent buffers derived from each file’s EDGE chunk, including geometric buffer growth. None disables the limit. The mapped graph data itself is not allocated on the heap.

Filesystem errors retain their std::io::Error source, including when path does not exist.

Source

pub fn from_commit_graphs_dir(path: &Path, object_hash: Kind) -> Result<Self>

Instantiate a commit graph from the directory containing all of its files.

Chain entries and graph files must use object_hash.

Source

pub fn from_file(path: &Path, object_hash: Kind) -> Result<Self>

Instantiate a commit graph from a .git/objects/info/commit-graph or .git/objects/info/commit-graphs/graph-*.graph file.

The graph file must use object_hash.

Source

pub fn from_info_dir(info_dir: &Path, object_hash: Kind) -> Result<Self>

Instantiate a commit graph from an .git/objects/info directory.

Chain entries and graph files must use object_hash.

Source

pub fn new(files: Vec<File>) -> Result<Self>

Create a new commit graph from a list of files.

Invalid file combinations are classified as gix_error::Class::Validation.

Source§

impl Graph

Source

pub fn verify_integrity<E>( &self, processor: impl FnMut(&Commit<'_>) -> Result<(), E>, ) -> Result<Outcome>
where E: Error + Send + Sync + 'static,

Traverse all commits in the graph and call processor(&commit) -> Result<(), E> on it while verifying checksums.

When processor returns an error, the entire verification is stopped and the error returned.

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

§

impl UnwindSafe for Graph

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> 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.