Skip to main content

ps_ecc/long/header/overlap_factor/methods/
count.rs

1use super::super::OverlapFactor;
2
3impl OverlapFactor {
4    /// Returns the nominal coverage count: the approximate number of
5    /// codewords protecting each byte (1 to 4).
6    #[inline]
7    #[must_use]
8    pub const fn count(self) -> u8 {
9        match self {
10            Self::Simple => 1,
11            Self::Double => 2,
12            Self::Triple => 3,
13            Self::Quadruple => 4,
14        }
15    }
16}
17
18#[cfg(test)]
19mod tests {
20    use crate::long::OverlapFactor;
21
22    #[test]
23    fn test_count_of_each_factor() {
24        assert_eq!(OverlapFactor::Simple.count(), 1);
25        assert_eq!(OverlapFactor::Double.count(), 2);
26        assert_eq!(OverlapFactor::Triple.count(), 3);
27        assert_eq!(OverlapFactor::Quadruple.count(), 4);
28    }
29}