pub struct ErasureCoding { /* private fields */ }
Expand description
Erasure coding abstraction.
Supports creation of parity records and recovery of missing data.
Implementations§
source§impl ErasureCoding
impl ErasureCoding
sourcepub fn new(scale: NonZeroUsize) -> Result<Self, String>
pub fn new(scale: NonZeroUsize) -> Result<Self, String>
Create new erasure coding instance.
Number of shards supported is 2^scale
, half of shards are source data and the other half
are parity.
sourcepub fn max_shards(&self) -> usize
pub fn max_shards(&self) -> usize
Max number of shards supported (both source and parity together)
sourcepub fn extend(&self, source: &[Scalar]) -> Result<Vec<Scalar>, String>
pub fn extend(&self, source: &[Scalar]) -> Result<Vec<Scalar>, String>
Extend sources using erasure coding.
Returns parity data.
sourcepub fn recover(&self, shards: &[Option<Scalar>]) -> Result<Vec<Scalar>, String>
pub fn recover(&self, shards: &[Option<Scalar>]) -> Result<Vec<Scalar>, String>
Recovery of missing shards from given shards (at least 1/2 should be Some
).
Both in input and output source shards are interleaved with parity shards: source, parity, source, parity, …
sourcepub fn recover_poly(
&self,
shards: &[Option<Scalar>],
) -> Result<Polynomial, String>
pub fn recover_poly( &self, shards: &[Option<Scalar>], ) -> Result<Polynomial, String>
Recovery of missing shards from given shards (at least 1/2 should be Some
) in form of
normalized polynomial (allows to not do inverse FFT afterwards if polynomial is desired).
Both in input and output source shards are interleaved with parity shards: source, parity, source, parity, …
sourcepub fn recover_source(
&self,
shards: &[Option<Scalar>],
) -> Result<impl ExactSizeIterator<Item = Scalar>, String>
pub fn recover_source( &self, shards: &[Option<Scalar>], ) -> Result<impl ExactSizeIterator<Item = Scalar>, String>
Recovery of source shards from given shards (at least 1/2 should be Some
).
The same as ErasureCoding::recover()
, but returns only source shards in form of an
iterator.
sourcepub fn extend_commitments(
&self,
commitments: &[Commitment],
) -> Result<Vec<Commitment>, String>
pub fn extend_commitments( &self, commitments: &[Commitment], ) -> Result<Vec<Commitment>, String>
Extend commitments using erasure coding.
Returns both source and parity commitments interleaved.
Trait Implementations§
source§impl Clone for ErasureCoding
impl Clone for ErasureCoding
source§fn clone(&self) -> ErasureCoding
fn clone(&self) -> ErasureCoding
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ErasureCoding
impl RefUnwindSafe for ErasureCoding
impl Send for ErasureCoding
impl Sync for ErasureCoding
impl Unpin for ErasureCoding
impl UnwindSafe for ErasureCoding
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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