Skip to main content

ps_ecc/long/header/
mod.rs

1mod codec;
2mod magic;
3mod methods;
4mod overlap_factor;
5mod utils;
6
7use codec::RS;
8pub use magic::LONG_ECC_HEADER_MAGIC;
9pub use overlap_factor::OverlapFactor;
10
11/// The 32-byte header of a long ECC codeword.
12///
13/// Records the codec geometry (error-correction capability, overlap
14/// factor, and lengths) and the payload checksum, and is itself protected
15/// by a dedicated checksum and parity bytes.
16#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
17#[allow(clippy::module_name_repetitions)]
18#[repr(C, align(16))]
19pub struct LongEccHeader {
20    /// magic number equal to [`LONG_ECC_HEADER_MAGIC`]
21    magic: u16,
22
23    /// encoding version number (currently 1)
24    version: u8,
25
26    /// error-correction capability (each correctable error costs two parity
27    /// bytes) in the low six bits, with the [`OverlapFactor`] packed into
28    /// the high two bits
29    parity: u8,
30
31    /// length of the full codeword, including header and parity
32    full_length: u32,
33
34    /// length of the encoded message
35    message_length: u32,
36
37    /// XXH64 hash of the version, parity, and length fields, folded to 32 bits
38    header_checksum: u32,
39
40    /// XXH64 checksum of the message and parity bytes
41    checksum: u64,
42
43    /// parity bytes forming an RS(32, 24) codeword
44    header_parity: [u8; 8],
45}