Skip to main content

PackIndex

Struct PackIndex 

Source
pub struct PackIndex {
    pub idx_path: PathBuf,
    pub pack_path: PathBuf,
    pub fanout: [u32; 256],
    pub is_promisor: bool,
    pub is_cruft: bool,
    /* private fields */
}
Expand description

Parsed pack index with fanout-accelerated OID lookup and in-place table reads.

Fields§

§idx_path: PathBuf

Absolute path to the .idx file.

§pack_path: PathBuf

Absolute path to the .pack file.

§fanout: [u32; 256]

256-entry fanout: cumulative count of objects with first OID byte <= b.

§is_promisor: bool

Sibling pack-*.promisor marker was present when this index was prepared.

§is_cruft: bool

Sibling pack-*.mtimes marker was present when this index was prepared (cruft pack).

Implementations§

Source§

impl PackIndex

Source

pub fn len(&self) -> usize

Number of objects in this index.

Source

pub fn is_empty(&self) -> bool

Whether this index contains no objects.

Source

pub fn hash_bytes(&self) -> usize

OID width in bytes (20 for SHA-1, 32 for SHA-256).

Source

pub fn oid_at(&self, i: usize) -> &[u8] ⓘ

OID bytes at sorted position i.

Source

pub fn offset_at(&self, i: usize) -> Result<u64>

Pack byte offset at sorted position i.

§Errors

Returns Error::CorruptObject when offset tables are malformed (including lazy-open indexes that skipped full verification).

Source

pub fn crc32_at(&self, i: usize) -> Option<u32>

CRC32 at sorted position i (None for version-1 indexes).

Source

pub fn find_position(&self, oid: &ObjectId) -> Option<usize>

Sorted-table position for oid, or None when absent or hash width mismatches.

Source

pub fn find_offset(&self, oid: &ObjectId) -> Result<Option<u64>>

Pack byte offset for oid, if present.

§Errors

Returns Error::CorruptObject when the matching row encodes an invalid offset.

Source

pub fn find_offset_monotonic( &self, oid: &ObjectId, cursor: &mut usize, ) -> Result<Option<u64>>

Like Self::find_offset but optimized for monotonically non-decreasing oid probes.

Updates cursor to the matching row on success. When the probe regresses (out-of-order input), falls back to fanout + binary search and resets cursor.

Source

pub fn contains(&self, oid: &ObjectId) -> Result<bool>

Whether this pack index contains the given OID.

Source

pub fn iter(&self) -> PackIndexIter<'_>

Iterate rows in OID sort order.

Source

pub fn next_pack_offset_after( &self, entry_offset: u64, pack_end: u64, ) -> Result<u64>

Smallest pack offset strictly greater than entry_offset, capped at pack_end.

Uses the cached offset-sorted table, so repeated calls cost a binary search each.

§Errors

Returns an error when the index has a malformed large-offset entry.

Source

pub fn crc32_for_pack_offset(&self, entry_offset: u64) -> Result<Option<u32>>

CRC32 for the index row at entry_offset, if any.

Source

pub fn find_position_by_offset_sorted( &self, offset: u64, ) -> Result<Option<usize>>

Index row position of the object stored at pack byte offset.

Uses an offset-sorted table that is built once per index (from the .rev sidecar when present) and shared by clones, so each lookup is a binary search.

Returns Ok(None) when no object starts at offset.

§Errors

Returns Error::CorruptObject when the index has a malformed large-offset entry.

Trait Implementations§

Source§

impl Clone for PackIndex

Source§

fn clone(&self) -> Self

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

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.