Skip to main content

PackFile

Struct PackFile 

Source
pub struct PackFile {
    pub version: u32,
    pub entries: Vec<PackObject>,
    pub checksum: ObjectId,
}

Fields§

§version: u32§entries: Vec<PackObject>§checksum: ObjectId

Implementations§

Source§

impl PackFile

Source

pub fn parse_sha1(bytes: &[u8]) -> Result<Self>

Source

pub fn parse(bytes: &[u8], format: ObjectFormat) -> Result<Self>

Source

pub fn parse_bundle(bundle: &Bundle) -> Result<Self>

Source

pub fn index_pack(bytes: &[u8], format: ObjectFormat) -> Result<PackWrite>

Source

pub fn parse_thin<F>( bytes: &[u8], format: ObjectFormat, external_base: F, ) -> Result<Self>

Source

pub fn verify_pack_stats( bytes: &[u8], format: ObjectFormat, ) -> Result<PackVerifyStats>

Walk the pack and produce per-object statistics matching the output of git verify-pack -v / git index-pack --verify-stat.

Objects are returned in pack offset order (the order git verify-pack -v prints them). Each entry carries the resolved object id, type and size, the in-pack byte span (size_in_pack = the offset delta to the next object, or to the trailing checksum for the last object), the in-pack offset, the delta chain depth (0 for undeltified objects), and — for deltas — the object id of the immediate base (which may itself be a delta). This mirrors builtin/index-pack.c’s show_pack_info.

Source

pub fn write_undeltified_sha1<T>(objects: &[T]) -> Result<PackWrite>

Source

pub fn write_undeltified<T>( objects: &[T], format: ObjectFormat, ) -> Result<PackWrite>

Write a pack with every object stored undeltified (no delta entries).

This is the simple, self-contained encoding; objects appear in the given order. For smaller output that exploits similarity between objects, use PackFile::write_packed.

Source

pub fn write_packed<T>(objects: &[T], format: ObjectFormat) -> Result<PackWrite>

Write a pack using sliding-window delta selection with git-compatible defaults (window DEFAULT_PACK_WINDOW, depth DEFAULT_PACK_DEPTH, ofs-deltas, self-contained).

Objects are grouped by type and ordered for good deltas, then each is compared against a window of previously emitted candidates; the smallest acceptable delta is kept, otherwise the object is stored undeltified. The result round-trips through PackFile::parse.

Source

pub fn write_packed_with_options<T>( objects: &[T], format: ObjectFormat, options: &PackWriteOptions, ) -> Result<PackWrite>

Like PackFile::write_packed but with caller-supplied PackWriteOptions (window, depth, base-reference style, and optional external thin bases).

Source

pub fn write_packed_with_known_ids( inputs: &[PackInput<'_>], format: ObjectFormat, ) -> Result<PackWrite>

Like PackFile::write_packed, but uses caller-supplied object ids instead of re-hashing each object before pack planning.

This is intended for object-database paths that reached each object by its id and already trust that id/object mapping. The function validates id formats and duplicate ids, but it does not re-hash object bodies; use PackFile::write_packed when the ids are not already known to be canonical.

Source

pub fn write_packed_with_known_ids_and_options( inputs: &[PackInput<'_>], format: ObjectFormat, options: &PackWriteOptions, ) -> Result<PackWrite>

Source

pub fn write_thin<T>( objects: &[T], format: ObjectFormat, external_bases: HashMap<ObjectId, EncodedObject>, ) -> Result<PackWrite>

Write a thin pack: objects may be deltified against external_bases that are not included in the pack, referenced by ref-delta to their object id.

The receiver must already have (or otherwise obtain) those base objects and resolve the pack with PackFile::parse_thin. Window and depth use the defaults; pass options via PackFile::write_packed_with_options with PackWriteOptions::with_thin_bases for finer control.

Trait Implementations§

Source§

impl Clone for PackFile

Source§

fn clone(&self) -> PackFile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PackFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for PackFile

Source§

impl PartialEq for PackFile

Source§

fn eq(&self, other: &PackFile) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PackFile

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.