pub struct RepairingChunkSet { /* private fields */ }Expand description
A structure designed to help incrementally reconstruct the original data of a ChunkSet
by collecting enough erasure-coded chunks, verifying their integrity, and performing RLNC decoding.
Implementations§
Source§impl RepairingChunkSet
impl RepairingChunkSet
Sourcepub fn add_chunk(
&mut self,
chunk: &ProofCarryingChunk,
) -> Result<(), DecdsError>
pub fn add_chunk( &mut self, chunk: &ProofCarryingChunk, ) -> Result<(), DecdsError>
Adds a ProofCarryingChunk to the RepairingChunkSet after validating its Merkle proof.
The chunk’s inclusion proof in this chunkset is verified against the commitment stored in RepairingChunkSet.
§Arguments
chunk- TheProofCarryingChunkto add.
§Returns
Returns a Result which is:
Ok(())if the chunk is successfully added and validated.Err(DecdsError::InvalidProofInChunk)if the chunk’s inclusion proof is invalid for this chunkset.Err(DecdsError::InvalidChunkMetadata)if the chunk’schunkset_iddoes not match thisRepairingChunkSet.Err(DecdsError::ChunkDecodingFailed)if the underlying RLNC decoding operation fails.
Sourcepub fn add_chunk_unvalidated(
&mut self,
chunk: &ProofCarryingChunk,
) -> Result<(), DecdsError>
pub fn add_chunk_unvalidated( &mut self, chunk: &ProofCarryingChunk, ) -> Result<(), DecdsError>
Adds a ProofCarryingChunk to the RepairingChunkSet without validating its Merkle proof.
This method is intended for use when proof validation has already occurred.
§Arguments
chunk- TheProofCarryingChunkto add.
§Returns
Returns a Result which is:
Ok(())if the chunk is successfully added.Err(DecdsError::InvalidChunkMetadata)if the chunk’schunkset_iddoes not match thisRepairingChunkSet.Err(DecdsError::ChunksetReadyToRepair)if the chunkset is ready to repair, no more chunks are required. Just callrepair.Err(DecdsError::ChunkDecodingFailed)if the underlying RLNC decoding operation fails.
Sourcepub fn is_ready_to_repair(&self) -> bool
pub fn is_ready_to_repair(&self) -> bool
Checks if enough useful erasure-coded chunks have been collected to repair the original data for this chunkset.
Sourcepub fn repair(self) -> Result<Vec<u8>, DecdsError>
pub fn repair(self) -> Result<Vec<u8>, DecdsError>
Repairs the original data of the chunkset if enough chunks have been collected.
This consumes the RepairingChunkSet as the decoding process is final.
§Returns
Returns a Result which is:
Ok(Vec<u8>)containing the repaired original data if successful.Err(DecdsError::ChunksetNotYetReadyToRepair)if not enough chunks have been added yet.Err(DecdsError::ChunksetRepairingFailed)if an error occurs during the RLNC decoding process.
Auto Trait Implementations§
impl Freeze for RepairingChunkSet
impl RefUnwindSafe for RepairingChunkSet
impl Send for RepairingChunkSet
impl Sync for RepairingChunkSet
impl Unpin for RepairingChunkSet
impl UnwindSafe for RepairingChunkSet
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