Skip to main content

PackSink

Trait PackSink 

Source
pub trait PackSink: MaybeSend {
    // Required methods
    fn write(
        &mut self,
        chunk: Bytes,
    ) -> impl Future<Output = Result<(), StoreError>> + MaybeSend;
    fn commit(
        self,
    ) -> impl Future<Output = Result<CommitOutcome, StoreError>> + MaybeSend;
    fn abort(self) -> impl Future<Output = ()> + MaybeSend;

    // Provided method
    fn commit_with_root(
        self,
        _content_root: Hash,
    ) -> impl Future<Output = Result<CommitOutcome, StoreError>> + MaybeSend
       where Self: Sized { ... }
}
Expand description

An in-progress blob upload.

Memory is bounded by a backend constant (one part, e.g. an R2 multipart part or a write buffer), never by the blob. Dropping a sink without commit or abort leaves nothing visible; its staged bytes may leak until the backend reclaims them (a temp-file sweep natively, R2’s abort-incomplete-multipart-upload lifecycle rule).

Required Methods§

Source

fn write( &mut self, chunk: Bytes, ) -> impl Future<Output = Result<(), StoreError>> + MaybeSend

Append a chunk. Writing past the declared length is StoreError::Invalid.

Source

fn commit( self, ) -> impl Future<Output = Result<CommitOutcome, StoreError>> + MaybeSend

Make the blob visible, only if BLAKE3(bytes) == key and the total equals the declared length; otherwise StoreError::Invalid and nothing is visible (a streaming backend withholds its final part until the hash verifies).

Object keys (BlobNamespace::Object, BlobNamespace::ObjectOffsets) refuse this form: use Self::commit_with_root.

Source

fn abort(self) -> impl Future<Output = ()> + MaybeSend

Discard the upload; nothing becomes visible.

Provided Methods§

Source

fn commit_with_root( self, _content_root: Hash, ) -> impl Future<Output = Result<CommitOutcome, StoreError>> + MaybeSend
where Self: Sized,

Make an object blob visible, only if the total equals the declared length and BLAKE3(bytes) == content_root (the key is the object id, so it cannot be the hash of the bytes). Verification and visibility are as for Self::commit: a streaming backend withholds its final byte until the root verifies. A pack or marker key is StoreError::Invalid. A backend that cannot verify a root is StoreError::Unsupported, which is the default.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§