gix_commitgraph

Struct File

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

A single commit-graph file.

All operations on a File are local to that graph file. Since a commit graph can span multiple files, all interesting graph operations belong on Graph.

Implementations§

Source§

impl File

Access

Source

pub fn base_graph_count(&self) -> u8

The number of base graphs that this file depends on.

Source

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

Returns the commit data for the commit located at the given lexicographical position.

pos must range from 0 to self.num_commits().

§Panics

Panics if pos is out of bounds.

Source

pub fn object_hash(&self) -> Kind

The kind of hash used in this File.

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

Source

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

Returns an object id at the given index in our list of (sorted) hashes. The position ranges from 0 to self.num_commits()

Source

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

Return an iterator over all object hashes stored in the base graph.

Source

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

return an iterator over all commits in this file.

Source

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

Return an iterator over all object hashes stored in this file.

Source

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

Translate the given object hash to its position within this file, if present.

Source

pub fn num_commits(&self) -> u32

Returns the number of commits in this graph file.

The maximum valid file::Position that can be used with this file is one less than num_commits().

Source

pub fn path(&self) -> &Path

Returns the path to this file.

Source§

impl File

Source

pub fn at(path: impl AsRef<Path>) -> Result<File, Error>

Try to parse the commit graph file at path.

Source

pub fn new(data: Mmap, path: PathBuf) -> Result<File, Error>

A lower-level constructor which constructs a new instance directly from the mapping in data, assuming that it originated from path.

Note that path is only used for verification of the hash its basename contains, but otherwise is not of importance.

Source§

impl File

Verification

Source

pub fn checksum(&self) -> &oid

Returns the trailing checksum over the entire content of this file.

Source

pub fn traverse<'a, E, Processor>( &'a self, processor: Processor, ) -> Result<Outcome, Error<E>>
where E: Error + 'static, Processor: FnMut(&Commit<'a>) -> Result<(), E>,

Traverse all commits stored in this file and call processor(commit) -> Result<(), Error> on it.

If the processor fails, the iteration will be stopped and the entire call results in the respective error.

Source

pub fn verify_checksum(&self) -> Result<ObjectId, (ObjectId, ObjectId)>

Assure the checksum matches the actual checksum over all content of this file, excluding the trailing checksum itself.

Return the actual checksum on success or (actual checksum, expected checksum) if there is a mismatch.

Trait Implementations§

Source§

impl Debug for File

Source§

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

Formats the value using the given formatter. Read more
Source§

impl TryFrom<&Path> for File

Source§

type Error = Error

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

fn try_from(path: &Path) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for File

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.