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
impl PackComposer
pub fn new( format: ObjectFormat, count: u32, max_pack_bytes: u64, output: &mut impl Write, ) -> Result<PackComposer, Error>
pub fn position(&self) -> u64
pub fn checksum(&self) -> Option<ObjectId>
pub fn start_entry( &mut self, entry: CompressedEntry, output: &mut impl Write, ) -> Result<(), Error>
pub fn write_compressed( &mut self, bytes: &[u8], output: &mut impl Write, ) -> Result<(), Error>
Sourcepub fn start_segment(&mut self, objects: u32, bytes: u64) -> Result<(), Error>
pub fn start_segment(&mut self, objects: u32, bytes: u64) -> Result<(), Error>
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.
pub fn finish_segment(&mut self) -> Result<(), Error>
Sourcepub fn finish_entry(&mut self) -> Result<IndexEntry, Error>
pub fn finish_entry(&mut self) -> Result<IndexEntry, Error>
Close the current entry after its exact compressed length was supplied. The returned metadata describes the newly encoded pack, not its source.