Struct git_pack::multi_index::File
source · [−]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
sourceimpl File
impl File
sourcepub fn write_from_index_paths<P>(
index_paths: Vec<PathBuf>,
out: impl Write,
progress: P,
should_interrupt: &AtomicBool,
_: Options
) -> Result<Outcome<P>, Error> where
P: Progress,
pub fn write_from_index_paths<P>(
index_paths: Vec<PathBuf>,
out: impl Write,
progress: P,
should_interrupt: &AtomicBool,
_: Options
) -> Result<Outcome<P>, Error> where
P: Progress,
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.
sourceimpl 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.
sourceimpl 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) -> Option<PrefixLookupResult>
pub fn lookup_prefix(&self, prefix: Prefix) -> 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.
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.
sourceimpl File
impl File
sourcepub fn verify_checksum(
&self,
progress: impl Progress,
should_interrupt: &AtomicBool
) -> Result<ObjectId, Error>
pub fn verify_checksum(
&self,
progress: impl 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<P>(
&self,
progress: P,
should_interrupt: &AtomicBool
) -> Result<(ObjectId, P), Error> where
P: Progress,
pub fn verify_integrity_fast<P>(
&self,
progress: P,
should_interrupt: &AtomicBool
) -> Result<(ObjectId, P), Error> where
P: Progress,
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, P, F>(
&self,
progress: P,
should_interrupt: &AtomicBool,
options: Options<F>
) -> Result<Outcome<P>, Error<Error>> where
P: Progress,
C: DecodeEntry,
F: Fn() -> C + Send + Clone,
pub fn verify_integrity<C, P, F>(
&self,
progress: P,
should_interrupt: &AtomicBool,
options: Options<F>
) -> Result<Outcome<P>, Error<Error>> where
P: Progress,
C: DecodeEntry,
F: Fn() -> C + Send + Clone,
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.
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more