Trait ecpool::ErasureCode[][src]

pub trait ErasureCode {
    fn data_fragments(&self) -> NonZeroUsize;
fn parity_fragments(&self) -> NonZeroUsize;
fn encode(&mut self, data: &[u8]) -> Result<Vec<FragmentBuf>>;
fn decode(&mut self, fragments: &[&Fragment]) -> Result<Vec<u8>>; fn fragments(&self) -> NonZeroUsize { ... }
fn reconstruct(
        &mut self,
        index: usize,
        fragments: &[&Fragment]
    ) -> Result<Vec<u8>> { ... } }

This trait allows for encoding and decoding data by using some erasure coding algorithm.

Required Methods

Returns the number of data fragments that the instance uses when encoding/decoding data.

Returns the number of parity fragments that the instance uses when encoding/decoding data.

Encodes the given data to fragments.

The result vector contains N data fragments and M parity fragments (where N = self.data_fragments() and M = self.parity_fragments()).

Decodes the original data from the given fragments.

Note whether the correctness of the result data has been validated depends on the implementations.

Provided Methods

The total number of data fragments and parity fragments of the instance.

Reconstructs the fragment specified by the given index from other fragments.

Implementors