pub enum Header {
Commit,
Tree,
Blob,
Tag,
RefDelta {
base_id: ObjectId,
},
OfsDelta {
base_distance: u64,
},
}
Expand description
The header portion of a pack data entry, identifying the kind of stored object.
Variants
Commit
The object is a commit
Tree
The object is a tree
Blob
The object is a blob
Tag
The object is a tag
RefDelta
Fields
base_id: ObjectId
Describes a delta-object which needs to be applied to a base. The base object is identified by the base_id
field
which is found within the parent repository.
Most commonly used for thin-packs when receiving pack files from the server to refer to objects that are not
part of the pack but expected to be present in the receivers repository.
Note
This could also be an object within this pack if the LSB encoded offset would be larger than 20 bytes, which is unlikely to happen.
The naming is exactly the same as the canonical implementation uses, namely REF_DELTA.
OfsDelta
Fields
base_distance: u64
Describes a delta-object present in this pack which acts as base for this object.
The base object is measured as a distance from this objects
pack offset, so that base_pack_offset = this_objects_pack_offset - base_distance
Note
The naming is exactly the same as the canonical implementation uses, namely OFS_DELTA.
Implementations
sourceimpl Header
impl Header
sourcepub fn verified_base_pack_offset(
pack_offset: Offset,
distance: u64
) -> Option<Offset>
pub fn verified_base_pack_offset(
pack_offset: Offset,
distance: u64
) -> Option<Offset>
Subtract distance
from pack_offset
safely without the chance for overflow or no-ops if distance
is 0.
sourcepub fn as_kind(&self) -> Option<Kind>
pub fn as_kind(&self) -> Option<Kind>
Convert the header’s object kind into git_object::Kind
if possible
sourcepub fn as_type_id(&self) -> u8
pub fn as_type_id(&self) -> u8
Convert this header’s object kind into the packs internal representation
sourceimpl Header
impl Header
sourcepub fn write_to(
&self,
decompressed_size_in_bytes: u64,
out: impl Write
) -> Result<usize>
pub fn write_to(
&self,
decompressed_size_in_bytes: u64,
out: impl Write
) -> Result<usize>
Encode this header along the given decompressed_size_in_bytes
into the out
write stream for use within a data pack.
Returns the amount of bytes written to out
.
decompressed_size_in_bytes
is the full size in bytes of the object that this header represents
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Header
impl<'de> Deserialize<'de> for Header
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Header
impl Ord for Header
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Header> for Header
impl PartialEq<Header> for Header
sourceimpl PartialOrd<Header> for Header
impl PartialOrd<Header> for Header
sourcefn partial_cmp(&self, other: &Header) -> Option<Ordering>
fn partial_cmp(&self, other: &Header) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Header
impl Eq for Header
impl StructuralEq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more