Skip to main content

ps_ecc/reed_solomon/methods/
parity_bytes.rs

1use crate::ReedSolomon;
2
3impl ReedSolomon {
4    /// Returns the number of parity bytes per codeword: `2 * parity`, two
5    /// per correctable error.
6    #[inline]
7    #[must_use]
8    pub const fn parity_bytes(&self) -> u8 {
9        self.parity() << 1
10    }
11}
12
13#[cfg(test)]
14mod tests {
15    use crate::{RSConstructorError, ReedSolomon};
16
17    #[test]
18    fn test_parity_bytes() -> Result<(), RSConstructorError> {
19        let rs = ReedSolomon::new(8)?;
20
21        assert_eq!(rs.parity_bytes(), 16);
22
23        Ok(())
24    }
25}