pub struct PackBuilder { /* private fields */ }Expand description
Pack builder for creating packfiles.
Implementations§
Source§impl PackBuilder
impl PackBuilder
Sourcepub fn new(compression: CompressionConfig) -> PackBuilder
pub fn new(compression: CompressionConfig) -> PackBuilder
Create a new pack builder.
Sourcepub fn for_repack(
compression: CompressionConfig,
delta_window: usize,
) -> PackBuilder
pub fn for_repack( compression: CompressionConfig, delta_window: usize, ) -> PackBuilder
Create a pack builder tuned for repacking an existing object corpus.
delta_window controls how many recently sorted objects are considered
as delta bases. A zero-sized window disables delta-base selection.
Sourcepub fn add(&mut self, hash: ContentHash, obj_type: ObjectType, data: Vec<u8>)
pub fn add(&mut self, hash: ContentHash, obj_type: ObjectType, data: Vec<u8>)
Add an object to the pack.
pub fn add_id(&mut self, id: PackObjectId, obj_type: ObjectType, data: Vec<u8>)
Sourcepub fn add_with_path(
&mut self,
hash: ContentHash,
obj_type: ObjectType,
data: Vec<u8>,
path: Option<String>,
)
pub fn add_with_path( &mut self, hash: ContentHash, obj_type: ObjectType, data: Vec<u8>, path: Option<String>, )
Add an object with a path hint for better delta grouping.
Objects sharing the same path (e.g. successive versions of src/main.rs)
will be sorted together for delta encoding, producing much better
compression ratios than size-only ordering.
pub fn add_with_path_id( &mut self, id: PackObjectId, obj_type: ObjectType, data: Vec<u8>, path: Option<String>, )
Sourcepub fn logical_id(&self) -> PackLogicalId
pub fn logical_id(&self) -> PackLogicalId
Compute the logical identity of the objects currently in this builder.
Path hints, compression, output order, and later delta-base selection do not participate in this root-spool-scoped identity.
Sourcepub fn build(self) -> Result<(Vec<u8>, Vec<u8>, PackStats), HeddleError>
pub fn build(self) -> Result<(Vec<u8>, Vec<u8>, PackStats), HeddleError>
Build the packfile and index.
Returns the pack data, index data, and statistics.
Sourcepub fn build_retaining_objects(
self,
) -> Result<(Vec<u8>, Vec<u8>, PackStats, Vec<(PackObjectId, ObjectType, Vec<u8>)>), HeddleError>
pub fn build_retaining_objects( self, ) -> Result<(Vec<u8>, Vec<u8>, PackStats, Vec<(PackObjectId, ObjectType, Vec<u8>)>), HeddleError>
Build the packfile and return ownership of the uncompressed inputs.
This is useful for callers that need to populate a decoded-object cache after durable installation. Returning the original buffers avoids cloning every payload before the build merely to keep it alive.