Struct git_odb::pack::data::File[][src]

pub struct File { /* fields omitted */ }

A pack data file

Implementations

impl File[src]

Decompression of objects

pub fn decompress_entry(
    &self,
    entry: &Entry,
    out: &mut [u8]
) -> Result<usize, Error>
[src]

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

pub fn entry(&self, offset: u64) -> Entry[src]

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>
[src]

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.

impl File[src]

Instantiation

pub fn at(path: impl AsRef<Path>) -> Result<File, Error>[src]

Try opening a data file at the given path.

impl File[src]

Checksums and verify checksums

pub fn checksum(&self) -> ObjectId[src]

The checksum in the trailer of this pack data file

pub fn verify_checksum(
    &self,
    progress: impl Progress
) -> Result<ObjectId, Error>
[src]

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.

impl File[src]

pub fn streaming_iter(&self) -> Result<BytesToEntriesIter<impl BufRead>, Error>[src]

Returns an iterator over Entries, without making use of the memory mapping.

impl File[src]

Information about the pack data file itself

pub fn version(&self) -> Version[src]

The pack data version of this file

pub fn num_objects(&self) -> u32[src]

The number of objects stored in this pack data file

pub fn data_len(&self) -> usize[src]

The length of all mapped data, including the pack header and the pack trailer

pub fn pack_end(&self) -> usize[src]

The position of the byte one past the last pack entry, or in other terms, the first byte of the trailing hash.

pub fn path(&self) -> &Path[src]

The path to the pack data file on disk

pub fn entry_slice(&self, slice: EntryRange) -> Option<&[u8]>[src]

Returns the pack data at the given slice if its range is contained in the mapped pack data

pub fn entry_crc32(&self, pack_offset: u64, size: usize) -> u32[src]

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.

Trait Implementations

impl TryFrom<&'_ Path> for File[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(path: &Path) -> Result<Self, Self::Error>[src]

Try opening a data file at the given path.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,