Skip to main content

reed_solomon_novelpoly/
lib.rs

1#![forbid(unused_crate_dependencies)]
2#![allow(clippy::needless_range_loop)]
3
4pub mod errors;
5pub use errors::*;
6
7pub mod util;
8pub use util::*;
9
10pub mod field;
11#[cfg(feature = "f256")]
12pub use self::field::f256;
13pub use self::field::f2e16;
14
15#[cfg(all(target_feature = "avx", feature = "avx"))]
16pub use self::field::faster8;
17
18mod novel_poly_basis;
19pub use self::novel_poly_basis::*;
20
21pub mod shard;
22pub use self::shard::Shard;
23
24pub mod wrapped_shard;
25pub use self::wrapped_shard::WrappedShard;
26
27#[cfg(feature = "with-alt-cxx-impl")]
28pub mod cxx;
29
30#[cfg(test)]
31mod test {
32	use crate::f2e16::encode_sub;
33
34	use super::*;
35	use reed_solomon_tester::{roundtrip, BYTES, N_SHARDS};
36
37	#[test]
38	fn novel_poly_basis_roundtrip() -> Result<()> {
39		roundtrip(
40			novel_poly_basis::encode::<WrappedShard>,
41			novel_poly_basis::reconstruct::<WrappedShard>,
42			&BYTES[..1337],
43			N_SHARDS,
44		)
45	}
46
47	/// Showcase the systematic nature of the algorithm.
48	#[test]
49	fn systematic_for_sure() {
50		let bytes = [1_u8, 2, 3, 4];
51		let bytes = bytes.as_slice();
52
53		let shards = encode_sub(bytes, 8, 4).unwrap();
54		let x = WrappedShard::from_iter(shards.iter().map(|x| x.0.to_be_bytes()));
55		assert_eq!(&x.into_inner()[..bytes.len()], bytes);
56	}
57}