[][src]Struct isa_l_erasure_coder::ErasureCoder

pub struct ErasureCoder { /* fields omitted */ }

Implementations

impl ErasureCoder[src]

#[must_use]pub const fn k(&self) -> usize[src]

#[must_use]pub const fn p(&self) -> usize[src]

#[must_use]pub const fn m(&self) -> usize[src]

#[must_use]pub fn encode_matrix(&self) -> &[u8][src]

#[must_use]pub fn new(k: usize, p: usize) -> Self[src]

#[must_use]pub fn new_with_encode_matrix(
    k: usize,
    p: usize,
    encode_matrix: Vec<u8>
) -> Self
[src]

pub fn encode<T, M>(&self, data: impl AsRef<[T]>, bufs: impl AsMut<[M]>) where
    T: AsRef<[u8]>,
    M: AsMut<[u8]>, 
[src]

Calculate the parities over k data slices of data and place it into p buffer slices.

The length of all data slices and all buffer slices must be equal.

Panics

Panics if the length of data is not equal to k or if the length of bufs is not equal to p.

pub fn decode<T: AsRef<[u8]>, M: AsMut<[u8]>>(
    &self,
    blocks: &[T],
    erased_idxs: &[usize],
    bufs: impl AsMut<[M]>
) -> Result<(), ErrorKind>
[src]

Decode erased blocks given their indexes and the available blocks

Uses gf_gen_decode_matrix_simple from the isa-l crate.

Errors

This function will return an error if the number of provided blocks is smaller than k or if no decode matrix can be found.

pub fn decode_with_fn<'a, T: AsRef<[u8]>, M: AsMut<[u8]>>(
    &'a self,
    blocks: &[T],
    erased_idxs: &'a [usize],
    gen_decode_matrix: fn(_: &'a [u8], _: &'a [usize], _: usize, _: usize) -> Option<Vec<u8>>,
    bufs: impl AsMut<[M]>
) -> Result<(), ErrorKind>
[src]

Decode erased blocks given their indexes and the available blocks

Uses a custom function to generate a decode matrix with the signature:

This example is not tested
fn gf_gen_decode_matrix_simple(
    encode_matrix: &[u8],
    erased_idxs: &[usize],
    k: usize,
    m: usize,
) -> Option<Vec<u8>>;

Errors

This function will return an error if the number of provided blocks is smaller than k or if no decode matrix can be found.

Trait Implementations

impl Debug for ErasureCoder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.