Skip to main content

PackIndex

Struct PackIndex 

Source
pub struct PackIndex {
    pub version: u32,
    pub fanout: [u32; 256],
    pub entries: Vec<PackIndexEntry>,
    pub pack_checksum: ObjectId,
    pub index_checksum: ObjectId,
}

Fields§

§version: u32§fanout: [u32; 256]§entries: Vec<PackIndexEntry>§pack_checksum: ObjectId§index_checksum: ObjectId

Implementations§

Source§

impl PackIndex

Source

pub fn write_v2_for_pack_sha1(pack_bytes: &[u8]) -> Result<PackIndexBuild>

Source

pub fn write_v2_for_pack( pack_bytes: &[u8], format: ObjectFormat, ) -> Result<PackIndexBuild>

Source

pub fn write_v2_for_pack_reader<R>( reader: &mut R, format: ObjectFormat, ) -> Result<PackStreamIndexBuild>
where R: Read + Seek,

Validate and index a pack from the reader’s current position to EOF.

This produces the same v2 .idx bytes and object metadata as PackIndex::write_v2_for_pack without requiring the caller to provide the pack as one contiguous byte slice. The reader is left positioned at EOF on success.

Source

pub fn write_v2_for_pack_reader_to_trailer<R>( reader: &mut R, format: ObjectFormat, ) -> Result<PackStreamIndexBuild>
where R: Read,

Validate and index a pack from the reader’s current position, stopping after the pack trailer checksum.

This is for transports where the pack length is not known in advance but the stream is expected to contain exactly one pack. It avoids forcing the caller to first materialize the pack only to learn its length.

Source

pub fn write_v2_for_pack_reader_with_len<R>( reader: &mut R, format: ObjectFormat, pack_len: u64, ) -> Result<PackStreamIndexBuild>
where R: Read,

Source

pub fn write_v2_for_pack_path( path: impl AsRef<Path>, format: ObjectFormat, ) -> Result<PackStreamIndexBuild>

Validate and index a pack from a filesystem path without loading the entire pack file into memory.

Source

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

Source

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

Source

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

Source

pub fn find(&self, oid: &ObjectId) -> Option<&PackIndexEntry>

Source

pub fn write_v2_sha1( entries: &[PackIndexEntry], pack_checksum: &ObjectId, ) -> Result<Vec<u8>>

Source

pub fn write_v2( format: ObjectFormat, entries: &[PackIndexEntry], pack_checksum: &ObjectId, ) -> Result<Vec<u8>>

Source

pub fn write_v1( format: ObjectFormat, entries: &[PackIndexEntry], pack_checksum: &ObjectId, ) -> Result<Vec<u8>>

Serialise a version-1 pack .idx: a 256-entry fanout, then for each object an inline 4-byte big-endian pack offset immediately followed by its object id (sorted by oid), then the pack checksum and a trailing index checksum. v1 has no CRC table and cannot represent offsets that do not fit in 32 bits.

Trait Implementations§

Source§

impl Clone for PackIndex

Source§

fn clone(&self) -> PackIndex

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 PackIndex

Source§

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

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

impl Eq for PackIndex

Source§

impl PartialEq for PackIndex

Source§

fn eq(&self, other: &PackIndex) -> 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 PackIndex

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.