Skip to main content

decode

Function decode 

Source
pub fn decode(received: &[u8], parity: u8) -> Result<Codeword<'_>, DecodeError>
Expand description

Verifies the error-correcting code and returns the message.

Correctable corruption is repaired. For codewords longer than 255 bytes, the parity argument is ignored, since the header records the parity, and bytes beyond the full length recorded in the header are discarded, so input rejected by validate may still decode successfully.

ยงErrors

For codewords of at most 255 bytes:

  • InsufficientParityBytes is returned if parity > length / 2.
  • RSConstructorError is returned if parity otherwise exceeds crate::MAX_PARITY.
  • RSDecodeError is returned if decoding fails.

For longer codewords:

  • LongEccDecodeError is returned if decoding fails.