1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct Flags {
    data: u8,
}

impl Flags {
    #[inline]
    pub fn from(input: u8) -> Self {
        Self { data: input & 0x3f }
    }

    #[inline]
    fn get_bit(&self, i: i8) -> bool {
        (self.data >> i) & 0x1 != 0
    }

    #[allow(dead_code)] // Remove upon first use
    #[inline]
    pub fn is_mandatory(&self) -> bool {
        self.get_bit(0)
    }

    #[inline]
    pub fn is_hidden(&self) -> bool {
        self.get_bit(1)
    }

    #[allow(dead_code)] // Remove upon first use
    #[inline]
    pub fn reserved_bits_ok(&self) -> bool {
        (2..6).into_iter().all(|i| !self.get_bit(i))
    }
}