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. 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
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