encode_source_block

Function encode_source_block 

Source
pub fn encode_source_block(
    source_block: &[u8],
    max_source_symbols: usize,
    nb_repair: usize,
) -> Result<(Vec<Vec<u8>>, u32), &'static str>
Expand description

Encodes a source block into encoding symbols using Raptor codes.

§Parameters

  • source_block: A slice of vectors containing the source symbols.
  • max_source_symbols: Max number of source symbols inside the source block
  • nb_repair: The number of repair symbols to be generated.

§Returns

a Tuple

  • Vec<Vec<u8>> : A vector of vectors of bytes representing the encoding symbols (source symbols + repair symbol).
  • u32 : Number of source symbols (k)
  • Err(&'static str) if the encoder could not be created.
    This can happen, for example, if partitioning the source_block results in
    too few encoding symbols (k < 4), which would lead to an under-specified matrix.

The function uses Raptor codes to generate the specified number of repair symbols from the source block.