Struct gix_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§

source§

impl File

source

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

Access methods

source

pub fn version(&self) -> Version

Returns the version of the multi-index file.

source

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.

source

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.

source

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

source

pub fn object_hash(&self) -> Kind

Returns the kind of hash function used for object ids available in this index.

source

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.

source

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

source

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().

source

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.

source

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().

source

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

pub fn iter(&self) -> impl Iterator<Item = Entry> + '_

Return an iterator over all entries within this file.

source§

impl File

source

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.

source

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.

source

pub fn verify_integrity<C, F>( &self, progress: &mut dyn DynNestedProgress, should_interrupt: &AtomicBool, options: Options<F>, ) -> Result<Outcome, Error<Error>>
where 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.

source§

impl File

Initialization

source

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

Open the multi-index file at the given path.

Trait Implementations§

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 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>,

§

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>,

§

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.