pub struct Entry {
pub header: Header,
pub decompressed_size: u64,
pub data_offset: Offset,
pub encoded_header_size: u16,
}Expand description
An representing an full- or delta-object within a pack
Fields§
§header: HeaderThe entry’s header
decompressed_size: u64The decompressed size of the entry in bytes.
Note that for non-delta entries this will be the size of the object itself.
data_offset: Offsetabsolute offset to compressed object data in the pack, just behind the entry’s header
encoded_header_size: u16The amount of bytes used to encode the entry header in the pack.
Git accepts non-canonical size encodings in pack entry headers. These are encodings that
continue the variable-length size field even though the remaining size bits are zero, for
example b3 00 for a blob of size 3 instead of the canonical single-byte 33.
Git does not usually write such headers itself, but they can appear when pack data is reused
verbatim, for example when a server constructs fetch or clone responses from already stored
pack entries. Readers have to preserve the byte length that was actually consumed: recomputing
the canonical length from the decoded size would shift Entry::pack_offset() backwards and
make ofs-delta base-offset calculations refer to the wrong entry.
A value of 0 means the actual length is unknown, causing Entry::header_size() to
recompute the canonical length from the decoded size. This is useful for deserializing data
produced by older versions.
Implementations§
Source§impl Entry
Decoding
impl Entry
Decoding
Source§impl Entry
Access
impl Entry
Access
Sourcepub fn checked_base_pack_offset(&self, distance: u64) -> Option<Offset>
pub fn checked_base_pack_offset(&self, distance: u64) -> Option<Offset>
Compute the pack offset to the base entry of the object represented by this entry, or
return None if the distance would underflow or is invalid.
Sourcepub fn base_pack_offset(&self, distance: u64) -> Offset
pub fn base_pack_offset(&self, distance: u64) -> Offset
Compute the pack offset to the base entry of the object represented by this entry.
§Panics
Panics if the distance will cause an underflow or is invalid.
Sourcepub fn pack_offset(&self) -> Offset
pub fn pack_offset(&self) -> Offset
The pack offset at which this entry starts
Sourcepub fn header_size(&self) -> usize
pub fn header_size(&self) -> usize
The amount of bytes used to describe this entry in the pack.
For entries decoded from pack data this returns the actual encoded header length, including
non-canonical overlong size encodings accepted by Git. This is the length to use for offset
reconstruction because the header starts at Self::pack_offset() and the compressed data
starts at Entry::data_offset.
If Entry::encoded_header_size is 0, the actual encoded length is unknown and this falls
back to Header::size(), which computes the canonical serialized length from the decoded
header and decompressed size.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Entry
impl<'de> Deserialize<'de> for Entry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Entry
Source§impl Ord for Entry
impl Ord for Entry
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Entry
impl PartialOrd for Entry
impl StructuralPartialEq for Entry
Auto Trait Implementations§
impl Freeze for Entry
impl RefUnwindSafe for Entry
impl Send for Entry
impl Sync for Entry
impl Unpin for Entry
impl UnsafeUnpin for Entry
impl UnwindSafe for Entry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.