Struct git_pack::index::File[][src]

pub struct File { /* fields omitted */ }
Expand description

A representation of a pack index file

Implementations

Instantiation

Open the pack index file at the given path.

Iteration and access

Returns 20 bytes sha1 at the given index in our list of (sorted) sha1 hashes. The index ranges from 0 to self.num_objects()

Panics

If index is out of bounds.

Returns the offset into our pack data file at which to start reading the object at index.

Panics

If index is out of bounds.

Returns the CRC32 of the object at the given index.

Note: These are always present for index version 2 or higher.

Panics

If index is out of bounds.

Returns the index of the given SHA1 for use with the oid_at_index(), pack_offset_at_index() or crc32_at_index().

An iterator over all Entries of this index file.

Return a vector of ascending offsets into our respective pack data file.

Useful to control an iteration over all pack entries in a cache-friendly way.

Traversal with index

Iterate through all decoded objects in the given pack and handle them with a Processor, using an index to reduce waste at the cost of memory.

For more details, see the documentation on the traverse() method.

Verify and validate the content of the index file

Iterate through all decoded objects in the given pack and handle them with a Processor using a cache to reduce the amount of waste while decoding objects.

For more details, see the documentation on the traverse() method.

Traversal of pack data files using an index file

Iterate through all decoded objects in the given pack and handle them with a Processor. The return value is (pack-checksum, Outcome, progress), thus the pack traversal will always verify the whole packs checksum to assure it was correct. In case of bit-rod, the operation will abort early without verifying all objects using the interrupt mechanism mechanism.

Algorithms

Using the Options::algorithm field one can chose between two algorithms providing different tradeoffs. Both invoke new_processor() to create functions receiving decoded objects, their object kind, index entry and a progress instance to provide progress information.

Use thread_limit to further control parallelism and check to define how much the passed objects shall be verified beforehand.

Verify and validate the content of the index file

Returns the trailing hash stored at the end of this index file.

It’s a hash over all bytes of the index.

Returns the hash of the pack data file that this index file corresponds to.

It should crate::data::File::checksum() of the corresponding pack data file.

Validate that our index_checksum() matches the actual contents of this index file, and return it if it does.

The most thorough validation of integrity of both index file and the corresponding pack data file, if provided. Returns the checksum of the index file, the traversal outcome and the given progress if the integrity check is successful.

If pack is provided, it is expected (and validated to be) the pack belonging to this index. It will be used to validate internal integrity of the pack before checking each objects integrity is indeed as advertised via its SHA1 as stored in this index, as well as the CRC32 hash. The last member of the Option is a function returning an implementation of crate::cache::DecodeEntry to be used if the index::traverse::Algorithm is Lookup. To set this to None, use None::<(_, _, _, fn() -> crate::cache::Never)>.

The thread_limit optionally specifies the amount of threads to be used for the pack traversal. make_cache is only used in case a pack is specified, use existing implementations in the crate::cache module.

Tradeoffs

The given progress is inevitably consumed if there is an error, which is a tradeoff chosen to easily allow using ? in the error case.

Various ways of writing an index file from pack entries

Write information about entries as obtained from a pack data file into a pack index file via the out stream. The resolver produced by make_resolver must resolve pack entries from the same pack data file that produced the entries iterator.

kind is the version of pack index to produce, use crate::index::Version::default() if in doubt. tread_limit is used for a parallel tree traversal for obtaining object hashes with optimal performance. root_progress is the top-level progress to stay informed about the progress of this potentially long-running computation.

Remarks
  • neither in-pack nor out-of-pack Ref Deltas are supported here, these must have been resolved beforehand.
  • make_resolver() will only be called after the iterator stopped returning elements and produces a function that provides all bytes belonging to a pack entry writing them to the given mutable output Vec. It should return None if the entry cannot be resolved from the pack that produced the entries iterator, causing the write operation to fail.

Basic file information

The version of the pack index

The path of the opened index file

The amount of objects stored in the pack and index

Trait Implementations

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.