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
Describes a delta-object which needs to be applied to a base identified by base_id.
The base may occur anywhere in the same pack or in the parent repository, as it does in a thin-pack.
The naming is exactly the same as the canonical implementation uses, namely REF_DELTA.
OfsDelta
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§
Source§impl 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 gix_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
Source§impl Header
impl Header
Sourcepub fn write_to(
&self,
decompressed_size_in_bytes: u64,
out: &mut dyn Write,
) -> Result<usize>
pub fn write_to( &self, decompressed_size_in_bytes: u64, out: &mut dyn 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
Sourcepub fn size(&self, decompressed_size: u64) -> usize
pub fn size(&self, decompressed_size: u64) -> usize
The size of the header in bytes when written in canonical form.
This is the number of bytes Self::write_to() would emit for decompressed_size.
It does not inspect existing pack bytes and therefore does not preserve non-canonical
overlong size encodings. Use data::Entry::header_size() for decoded entries when the
result has to match the header length present in the pack.
Trait Implementations§
impl Copy for Header
Source§impl<'de> Deserialize<'de> for Header
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Header
serde only.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 Header
Source§impl Ord for Header
impl Ord for Header
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 Header
impl PartialOrd for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
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.