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
fn data_fragments(&self) -> NonZeroUsize
Returns the number of data fragments that the instance uses when encoding/decoding data.
fn parity_fragments(&self) -> NonZeroUsize
Returns the number of parity fragments that the instance uses when encoding/decoding data.
fn encode(&mut self, data: &[u8]) -> Result<Vec<FragmentBuf>>
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()
).
fn decode(&mut self, fragments: &[&Fragment]) -> Result<Vec<u8>>
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
fn fragments(&self) -> NonZeroUsize
The total number of data fragments and parity fragments of the instance.
fn reconstruct(
&mut self,
index: usize,
fragments: &[&Fragment]
) -> Result<Vec<u8>>
&mut self,
index: usize,
fragments: &[&Fragment]
) -> Result<Vec<u8>>
Reconstructs the fragment specified by the given index from other fragments.
Implementors
impl ErasureCode for LibErasureCoder
impl ErasureCode for ReplicaCoder