pub struct SplitStreamBuilder<ObjectID: FsVerityHashValue> {
repo: Arc<Repository<ObjectID>>,
entries: Vec<SplitStreamEntry<ObjectID>>,
total_external_size: u64,
content_type: u64,
stream_refs: UniqueVec<ObjectID>,
named_refs: BTreeMap<Box<str>, usize>,
}Expand description
Builder for constructing a split stream with parallel object storage.
This builder collects entries (inline data and pending external object handles),
then serializes them all at once when finish() is called. This approach:
- Allows all external handles to be awaited in parallel
- Enables proper deduplication of ObjectIDs
- Writes the stream in one clean pass after all IDs are known
§Example
let mut builder = SplitStreamBuilder::new(repo.clone(), content_type);
builder.push_inline(header_bytes);
builder.push_external(storage_handle, file_size);
builder.push_inline(padding);
let object_id = builder.finish().await?;Fields§
§repo: Arc<Repository<ObjectID>>§entries: Vec<SplitStreamEntry<ObjectID>>§total_external_size: u64§content_type: u64§stream_refs: UniqueVec<ObjectID>§named_refs: BTreeMap<Box<str>, usize>Implementations§
Source§impl<ObjectID: FsVerityHashValue> SplitStreamBuilder<ObjectID>
impl<ObjectID: FsVerityHashValue> SplitStreamBuilder<ObjectID>
Sourcepub fn new(repo: Arc<Repository<ObjectID>>, content_type: u64) -> Self
pub fn new(repo: Arc<Repository<ObjectID>>, content_type: u64) -> Self
Create a new split stream builder.
Sourcepub fn push_inline(&mut self, data: &[u8])
pub fn push_inline(&mut self, data: &[u8])
Append inline data to the stream.
Adjacent inline data will be coalesced to avoid fragmentation.
Sourcepub fn push_external(&mut self, handle: JoinHandle<Result<ObjectID>>, size: u64)
pub fn push_external(&mut self, handle: JoinHandle<Result<ObjectID>>, size: u64)
Append an external object being stored in background.
The handle should resolve to the ObjectID when the storage completes.
Sourcepub fn add_named_stream_ref(&mut self, name: &str, verity: &ObjectID)
pub fn add_named_stream_ref(&mut self, name: &str, verity: &ObjectID)
Add an externally-referenced stream with the given name.
The name has no meaning beyond the scope of this file: it is meant to be used to link to associated data when reading the file back again. For example, for OCI config files, this might refer to a layer splitstream via its DiffId.
Sourcepub async fn finish(self) -> Result<ObjectID>
pub async fn finish(self) -> Result<ObjectID>
Finalize: await all handles, build the splitstream, store it.
This method:
- Awaits all external handles to get ObjectIDs
- Builds a UniqueVec
for deduplication - Creates a SplitStreamWriter and replays all entries
- Stores the final splitstream in the repository
Returns the fs-verity object ID of the stored splitstream.