Struct gix_commitgraph::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
impl File
Access
sourcepub fn base_graph_count(&self) -> u8
pub fn base_graph_count(&self) -> u8
The number of base graphs that this file depends on.
sourcepub fn commit_at(&self, pos: Position) -> Commit<'_>
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.
sourcepub fn object_hash(&self) -> Kind
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.
sourcepub fn id_at(&self, pos: Position) -> &oid
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()
sourcepub fn iter_base_graph_ids(&self) -> impl Iterator<Item = &oid>
pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = &oid>
Return an iterator over all object hashes stored in the base graph.
sourcepub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>>
pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>>
return an iterator over all commits in this file.
sourcepub fn iter_ids(&self) -> impl Iterator<Item = &oid>
pub fn iter_ids(&self) -> impl Iterator<Item = &oid>
Return an iterator over all object hashes stored in this file.
sourcepub fn lookup(&self, id: impl AsRef<oid>) -> Option<Position>
pub fn lookup(&self, id: impl AsRef<oid>) -> Option<Position>
Translate the given object hash to its position within this file, if present.
sourcepub fn num_commits(&self) -> u32
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§impl File
impl File
sourcepub fn at(path: impl AsRef<Path>) -> Result<File, Error>
pub fn at(path: impl AsRef<Path>) -> Result<File, Error>
Try to parse the commit graph file at path
.
sourcepub fn new(data: Mmap, path: PathBuf) -> Result<File, Error>
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
impl File
Verification
sourcepub fn checksum(&self) -> &oid
pub fn checksum(&self) -> &oid
Returns the trailing checksum over the entire content of this file.
sourcepub fn traverse<'a, E, Processor>(
&'a self,
processor: Processor,
) -> Result<Outcome, Error<E>>
pub fn traverse<'a, E, Processor>( &'a self, processor: Processor, ) -> Result<Outcome, Error<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.