encode

Function encode 

Source
pub fn encode(
    chunk: &[u8],
    k: usize,
    n: usize,
) -> BpResult<Vec<EncodedFragment>>
Expand description

Split chunk into k source symbols and produce n encoded fragments.

The first k fragments are systematic (identity coding vectors), so the original symbols can always be recovered from frags[..k] without any linear algebra. The remaining n-k fragments use random coefficients drawn from GF(2⁸) for redundancy.

§Arguments

  • chunk — raw bytes of the chunk to encode.
  • k — number of source symbols (recovery threshold).
  • n — total number of encoded fragments to produce (n ≥ k).

§Errors

Returns an error if n < k or chunk is empty.