SplitStreamBuilder

Struct SplitStreamBuilder 

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

Source

pub fn new(repo: Arc<Repository<ObjectID>>, content_type: u64) -> Self

Create a new split stream builder.

Source

pub fn push_inline(&mut self, data: &[u8])

Append inline data to the stream.

Adjacent inline data will be coalesced to avoid fragmentation.

Source

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.

Source

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.

Source

pub async fn finish(self) -> Result<ObjectID>

Finalize: await all handles, build the splitstream, store it.

This method:

  1. Awaits all external handles to get ObjectIDs
  2. Builds a UniqueVec for deduplication
  3. Creates a SplitStreamWriter and replays all entries
  4. Stores the final splitstream in the repository

Returns the fs-verity object ID of the stored splitstream.

Trait Implementations§

Source§

impl<ObjectID: FsVerityHashValue> Debug for SplitStreamBuilder<ObjectID>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<ObjectID> Freeze for SplitStreamBuilder<ObjectID>

§

impl<ObjectID> RefUnwindSafe for SplitStreamBuilder<ObjectID>
where ObjectID: RefUnwindSafe,

§

impl<ObjectID> Send for SplitStreamBuilder<ObjectID>

§

impl<ObjectID> Sync for SplitStreamBuilder<ObjectID>

§

impl<ObjectID> Unpin for SplitStreamBuilder<ObjectID>

§

impl<ObjectID> UnwindSafe for SplitStreamBuilder<ObjectID>
where ObjectID: UnwindSafe + RefUnwindSafe,

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V