Struct git_commitgraph::file::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 lexigraphical 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§

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

§

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 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.