Struct git_pack::data::File [−][src]
pub struct File {
pub id: u32,
// some fields omitted
}
Expand description
A pack data file
Fields
id: u32
A hash to represent the path
field when used with cache lookup, or a way to identify this pack by its location on disk.
Note that path
might not be canonicalized, thus different hashes might actually refer to the same pack on disk. This will
only lead to less efficient cache usage.
TODO: remove this intrinsic id as it will henceforth be handled separately by the object store
Implementations
Decompression of objects
Decompress the given entry
into out
and return the amount of bytes read from the pack data.
Note that this method does not resolve deltified objects, but merely decompresses their content
out
is expected to be large enough to hold entry.size
bytes.
Panics
If out
isn’t large enough to hold the decompressed entry
Obtain the Entry
at the given offset
into the pack.
The offset
is typically obtained from the pack index file.
pub fn decode_entry(
&self,
entry: Entry,
out: &mut Vec<u8>,
resolve: impl Fn(&oid, &mut Vec<u8>) -> Option<ResolvedBase>,
delta_cache: &mut impl DecodeEntry
) -> Result<Outcome, Error>
pub fn decode_entry(
&self,
entry: Entry,
out: &mut Vec<u8>,
resolve: impl Fn(&oid, &mut Vec<u8>) -> Option<ResolvedBase>,
delta_cache: &mut impl DecodeEntry
) -> Result<Outcome, Error>
Decode an entry, resolving delta’s as needed, while growing the out
vector if there is not enough
space to hold the result object.
The entry
determines which object to decode, and is commonly obtained with the help of a pack index file or through pack iteration.
resolve
is a function to lookup objects with the given ObjectId
, in case the full object id is used to refer to
a base object, instead of an in-pack offset.
delta_cache
is a mechanism to avoid looking up base objects multiple times when decompressing multiple objects in a row.
Use a Noop-Cache to disable caching alltogether at the cost of repeating work.
Instantiation
Checksums and verify checksums
pub 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>
Verifies that the checksum of the packfile over all bytes preceding it indeed matches the actual checksum,
returning the actual checksum equivalent to the return value of checksum()
if there
is no mismatch.
Note that if no progress
is desired, one can pass [git_features::progress::Discard
].
Have a look at index::File::verify_integrity(…)
for an
even more thorough integrity check.
Returns an iterator over Entries
, without making use of the memory mapping.
Information about the pack data file itself
The number of objects stored in this pack data file
The length of all mapped data, including the pack header and the pack trailer
The position of the byte one past the last pack entry, or in other terms, the first byte of the trailing hash.
Returns the pack data at the given slice if its range is contained in the mapped pack data
Returns the CRC32 of the pack data indicated by pack_offset
and the size
of the mapped data.
Note: finding the right size is only possible by decompressing the pack entry beforehand, or by using the (to be sorted) offsets stored in an index file.
Panics
If pack_offset
or size
are pointing to a range outside of the mapped pack data.