pub struct File { /* private fields */ }
Expand description
A representation of an index file for multiple packs at the same time, typically stored in a file named ‘multi-pack-index’.
Implementations§
source§impl File
impl File
sourcepub fn write_from_index_paths(
index_paths: Vec<PathBuf>,
out: &mut dyn Write,
progress: &mut dyn DynNestedProgress,
should_interrupt: &AtomicBool,
_: Options,
) -> Result<Outcome, Error>
pub fn write_from_index_paths( index_paths: Vec<PathBuf>, out: &mut dyn Write, progress: &mut dyn DynNestedProgress, should_interrupt: &AtomicBool, _: Options, ) -> Result<Outcome, Error>
Create a new multi-index file for writing to out
from the pack index files at index_paths
.
Progress is sent to progress
and interruptions checked via should_interrupt
.
source§impl File
impl File
Access methods
sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Returns the path from which the multi-index file was loaded.
Note that it might have changed in the mean time, or might have been removed as well.
sourcepub fn num_indices(&self) -> PackIndex
pub fn num_indices(&self) -> PackIndex
Returns the amount of indices stored in this multi-index file. It’s the same as File::index_names().len(), and returned as one past the highest known index.
sourcepub fn num_objects(&self) -> EntryIndex
pub fn num_objects(&self) -> EntryIndex
Returns the total amount of objects available for lookup, and returned as one past the highest known entry index
sourcepub fn object_hash(&self) -> Kind
pub fn object_hash(&self) -> Kind
Returns the kind of hash function used for object ids available in this index.
sourcepub fn checksum(&self) -> ObjectId
pub fn checksum(&self) -> ObjectId
Returns the checksum over the entire content of the file (excluding the checksum itself).
It can be used to validate it didn’t change after creation.
sourcepub fn index_names(&self) -> &[PathBuf]
pub fn index_names(&self) -> &[PathBuf]
Return all names of index files (*.idx
) whose objects we contain.
The corresponding pack can be found by replacing the .idx
extension with .pack
.
source§impl File
impl File
sourcepub fn oid_at_index(&self, index: EntryIndex) -> &oid
pub fn oid_at_index(&self, index: EntryIndex) -> &oid
Return the object id at the given index
, which ranges from 0 to File::num_objects().
sourcepub fn lookup_prefix(
&self,
prefix: Prefix,
candidates: Option<&mut Range<EntryIndex>>,
) -> Option<PrefixLookupResult>
pub fn lookup_prefix( &self, prefix: Prefix, candidates: Option<&mut Range<EntryIndex>>, ) -> Option<PrefixLookupResult>
Given a prefix
, find an object that matches it uniquely within this index and return Some(Ok(entry_index))
.
If there is more than one object matching the object Some(Err(())
is returned.
Finally, if no object matches the index, the return value is None
.
Pass candidates
to obtain the set of entry-indices matching prefix
, with the same return value as
one would have received if it remained None
. It will be empty if no object matched the prefix
.
sourcepub fn lookup(&self, id: impl AsRef<oid>) -> Option<EntryIndex>
pub fn lookup(&self, id: impl AsRef<oid>) -> Option<EntryIndex>
Find the index ranging from 0 to File::num_objects() that belongs to data associated with id
, or None
if it wasn’t found.
Use this index for finding additional information via File::pack_id_and_pack_offset_at_index()
.
sourcepub fn pack_id_and_pack_offset_at_index(
&self,
index: EntryIndex,
) -> (PackIndex, Offset)
pub fn pack_id_and_pack_offset_at_index( &self, index: EntryIndex, ) -> (PackIndex, Offset)
Given the index
ranging from 0 to File::num_objects(), return the pack index and its absolute offset into the pack.
The pack-index refers to an entry in the index_names
list, from which the pack can be derived.
source§impl File
impl File
sourcepub fn verify_checksum(
&self,
progress: &mut dyn Progress,
should_interrupt: &AtomicBool,
) -> Result<ObjectId, Error>
pub fn verify_checksum( &self, progress: &mut dyn Progress, should_interrupt: &AtomicBool, ) -> Result<ObjectId, Error>
Validate that our checksum()
matches the actual contents
of this index file, and return it if it does.
sourcepub fn verify_integrity_fast(
&self,
progress: &mut dyn DynNestedProgress,
should_interrupt: &AtomicBool,
) -> Result<ObjectId, Error>
pub fn verify_integrity_fast( &self, progress: &mut dyn DynNestedProgress, should_interrupt: &AtomicBool, ) -> Result<ObjectId, Error>
Similar to verify_integrity()
but without any deep inspection of objects.
Instead we only validate the contents of the multi-index itself.
sourcepub fn verify_integrity<C, F>(
&self,
progress: &mut dyn DynNestedProgress,
should_interrupt: &AtomicBool,
options: Options<F>,
) -> Result<Outcome, Error<Error>>
pub fn verify_integrity<C, F>( &self, progress: &mut dyn DynNestedProgress, should_interrupt: &AtomicBool, options: Options<F>, ) -> Result<Outcome, Error<Error>>
Similar to crate::Bundle::verify_integrity()
but checks all contained indices and their packs.
Note that it’s considered a failure if an index doesn’t have a corresponding pack.