pub struct BlobBuilder { /* private fields */ }Expand description
BlobBuilder provides an incremental way to construct a Blob from a stream of data.
This builder handles the division of input data into fixed-size ChunkSets, prepares RLNC-based erasure-coded chunks,
computes BLAKE3 digest of blob, and generates Merkle inclusion (in respective Chunksets) proof for proof-carrying chunks.
Implementations§
Source§impl BlobBuilder
impl BlobBuilder
pub fn num_bytes_absorbed_so_far(&self) -> usize
Sourcepub fn update(&mut self, data: &[u8]) -> Option<Vec<ProofCarryingChunk>>
pub fn update(&mut self, data: &[u8]) -> Option<Vec<ProofCarryingChunk>>
Updates the BlobBuilder with new data.
This method absorbs the provided data into the internal buffer. If enough
data accumulates to form a complete ChunkSet, it is processed (erasure-coded,
Merkle-proofed) and its resulting ProofCarryingChunks are returned.
You can call this method arbitrary number of times, before calling Self::finalize.
Note, you must call this method atleast once with non-empty input data, to not get
an error from Self::finalize - as you can’t build a blob over empty input data.
§Arguments
data- A byte slice containing the new data to be processed.
§Returns
An Option<Vec<ProofCarryingChunk>>.
Some(Vec<ProofCarryingChunk>)if one or moreChunkSets were completed and their chunks generated. These chunks carry Merkle proof-of-inclusion in respective Chunkset.Noneif no completeChunkSetwas formed or if the inputdatawas empty.
Sourcepub fn finalize(
self,
) -> Result<(Vec<ProofCarryingChunk>, BlobHeader), DecdsError>
pub fn finalize( self, ) -> Result<(Vec<ProofCarryingChunk>, BlobHeader), DecdsError>
Finalizes the BlobBuilder, processing any remaining buffered data
and constructing the BlobHeader.
This method pads any incomplete ChunkSet in the buffer with zeros,
processes it, computes the final blob digest, and builds the top-level
Merkle tree over chunkset root commitments, yielding the BlobHeader
and at max 16 proof-carrying chunks, if there was an incomplete chunkset,
which needed to be built.
§Returns
Returns a Result which is:
Ok((Vec<ProofCarryingChunk>, BlobHeader))containing either 0 or 16ProofCarryingChunks from last chunkset and theBlobHeaderfor the complete blob.Err(DecdsError::EmptyDataForBlob)if no data was ever absorbed by the builder.- Other
DecdsErrortypes may be returned from underlyingMerkleTree::newcalls.
Auto Trait Implementations§
impl Freeze for BlobBuilder
impl RefUnwindSafe for BlobBuilder
impl Send for BlobBuilder
impl Sync for BlobBuilder
impl Unpin for BlobBuilder
impl UnwindSafe for BlobBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more