Skip to main content

ps_ecc/long/header/methods/
full_length.rs

1use crate::long::LongEccHeader;
2
3impl LongEccHeader {
4    /// Returns the length of the full codeword, including the header and parity.
5    #[inline]
6    #[must_use]
7    pub const fn full_length(&self) -> u32 {
8        self.full_length
9    }
10}
11
12#[cfg(test)]
13mod tests {
14    use crate::long::{LongEccHeader, OverlapFactor};
15
16    type TestError = Box<dyn std::error::Error>;
17
18    #[test]
19    fn test_full_length_returns_constructor_value() -> Result<(), TestError> {
20        let header = LongEccHeader::new(2, OverlapFactor::Simple, 86, 50, 0)?;
21
22        assert_eq!(header.full_length(), 86);
23
24        Ok(())
25    }
26
27    #[test]
28    fn test_full_length_maximum_value() -> Result<(), TestError> {
29        // With zero parity, the codeword is the header plus the message, so the
30        // maximum full length pairs with a message of `u32::MAX - 32` bytes.
31        let header = LongEccHeader::new(0, OverlapFactor::Simple, u32::MAX, u32::MAX - 32, 0)?;
32
33        assert_eq!(header.full_length(), u32::MAX);
34
35        Ok(())
36    }
37}