Skip to main content

Crate ps_ecc

Crate ps_ecc 

Source
Expand description

Reed-Solomon error-correcting codes over GF(256).

The crate offers three layers of API:

  • The free functions encode, decode, and validate pick the appropriate format automatically: messages that fit a single Reed-Solomon codeword (at most 255 - 2 * parity bytes) are encoded directly, and longer messages use the long ECC format, which splits the message into segments of at most 255 bytes behind a checksummed header.
  • ReedSolomon encodes, validates, and corrects single codewords, either attached (parity || data in one slice) or detached (parity and data as separate slices).
  • Polynomial and euclidean expose the underlying GF(256) polynomial arithmetic.

The parity count parameter is the error-correction capability: the number of byte errors a codeword can recover from, each costing two parity bytes. It is capped at MAX_PARITY (63). The detached APIs instead take the generated parity bytes themselves, capped at MAX_PARITY_BYTES (126).

Structs§

Codeword
A decoded codeword exposing the message bytes.
LongEccHeader
The 32-byte header of a long ECC codeword.
ParityBytes
Stack-allocated parity bytes returned by crate::ReedSolomon::generate_parity.
Polynomial
A polynomial over GF(256) with at most 255 coefficients.
ReedSolomon
A Reed-Solomon codec over GF(256) for codewords of at most 255 bytes.

Enums§

Cow
A borrowed-or-owned byte buffer.
DecodeError
Errors returned by the free decode function.
EccError
Umbrella error over encoding and decoding.
EncodeError
Errors returned by the free encode function.
EuclideanError
Errors returned by euclidean.
GFError
Errors of GF(256) field arithmetic.
LongEccDecodeError
Errors of long ECC decoding.
LongEccEncodeError
Errors of long ECC encoding.
LongEccFastValidateError
LongEccHeaderConstructorError
Errors returned by LongEccHeader::new.
LongEccHeaderFromByteSliceError
Errors returned by LongEccHeader::from_byte_slice.
LongEccHeaderFromBytesError
Errors returned by LongEccHeader::from_bytes.
OverlapFactor
Approximate number of distinct codewords covering each byte.
PolynomialDivError
Errors of polynomial division and remainder.
PolynomialFromSliceError
Errors returned when constructing a Polynomial from a slice.
PolynomialMulError
Errors of polynomial multiplication.
PolynomialSetCoefficientsError
Errors returned by Polynomial::set_coefficients.
PolynomialXorError
Errors of polynomial XOR with a coefficient iterator.
RSComputeErrorsError
Errors returned by ReedSolomon::compute_errors.
RSConstructorError
Errors returned by ReedSolomon::new and by the detached-parity methods when the parity slice itself is invalid.
RSDecodeError
Errors returned by the decoding and correction methods of ReedSolomon.
RSEncodeError
Errors returned by ReedSolomon::encode.
RSGenerateParityError
Errors returned by ReedSolomon::generate_parity.

Constants§

MAX_PARITY
Maximum error-correction capability of a Reed-Solomon codec.
MAX_PARITY_BYTES
Maximum parity byte count, equal to MAX_PARITY * 2.

Functions§

decode
Verifies the error-correcting code and returns the message.
encode
Encodes a message by adding an error-correcting code.
euclidean
Extended Euclidean algorithm for Reed-Solomon decoding.
validate
Validates that a received codeword is pristine.