Skip to main content

ps_ecc/
lib.rs

1//! Reed-Solomon error-correcting codes over GF(256).
2//!
3//! The crate offers three layers of API:
4//!
5//! - The free functions [`encode`], [`decode`], and [`validate`] pick the
6//!   appropriate format automatically: messages that fit a single
7//!   Reed-Solomon codeword (at most `255 - 2 * parity` bytes) are encoded
8//!   directly, and longer messages use the long ECC format, which splits
9//!   the message into segments of at most 255 bytes behind a checksummed
10//!   header.
11//! - [`ReedSolomon`] encodes, validates, and corrects single codewords,
12//!   either attached (`parity || data` in one slice) or detached (parity
13//!   and data as separate slices).
14//! - [`Polynomial`] and [`euclidean`] expose the underlying GF(256)
15//!   polynomial arithmetic.
16//!
17//! The `parity` count parameter is the error-correction capability: the
18//! number of byte errors a codeword can recover from, each costing two
19//! parity bytes. It is capped at [`MAX_PARITY`] (63). The detached APIs
20//! instead take the generated parity bytes themselves, capped at
21//! [`MAX_PARITY_BYTES`] (126).
22
23mod codeword;
24mod cow;
25mod error;
26mod euclidean;
27mod finite_field;
28mod long;
29mod methods;
30mod polynomial;
31mod reed_solomon;
32
33pub use codeword::Codeword;
34pub use cow::Cow;
35pub use error::*;
36pub use euclidean::euclidean;
37pub use long::{LongEccHeader, OverlapFactor};
38pub use methods::*;
39pub use polynomial::Polynomial;
40pub use reed_solomon::*;