Skip to main content

PackComposer

Struct PackComposer 

Source
pub struct PackComposer { /* private fields */ }
Expand description

Assemble a version-2 pack without inflating/recompressing stored entries. All state is inline; each sink is supplied per call so a host can await storage/network operations between bounded writes. Preserve produced bytes. Any error is terminal and invalidates the entire partial output.

This is an encoding API, not a validator. The caller MUST authenticate the source streams and metadata, select unique IDs and an authorized object closure, and provide every delta base either in the pack or in the receiver (only when thin packs are allowed). Zlib bytes are copied unchanged. New headers, entry CRCs and the pack checksum reflect the output representation.

Implementations§

Source§

impl PackComposer

Source

pub fn new( format: ObjectFormat, count: u32, max_pack_bytes: u64, output: &mut impl Write, ) -> Result<Self>

Source

pub fn position(&self) -> u64

Source

pub fn checksum(&self) -> Option<ObjectId>

Source

pub fn start_entry( &mut self, entry: CompressedEntry, output: &mut impl Write, ) -> Result<()>

Source

pub fn write_compressed( &mut self, bytes: &[u8], output: &mut impl Write, ) -> Result<()>

Source

pub fn start_segment(&mut self, objects: u32, bytes: u64) -> Result<()>

Copy one complete authenticated source pack’s entry region, excluding its 12-byte header and object-format trailer. Source entries stay contiguous: every OFS distance is invariant under the segment’s shift. The host MUST prove unique IDs across all segments and include every REF base (or explicitly permit a thin output). This never parses bytes.

Source

pub fn finish_segment(&mut self) -> Result<()>

Source

pub fn finish_entry(&mut self) -> Result<IndexEntry>

Close the current entry after its exact compressed length was supplied. The returned metadata describes the newly encoded pack, not its source.

Source

pub fn finish(&mut self, output: &mut impl Write) -> Result<ObjectId>

Write the checksum only after all declared entries are complete. Successful repeated calls return the checksum without writing again.

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