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
34
bitflags::bitflags! {
    /// rANS Nx16 flags.
    #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
    pub struct Flags: u8 {
        /// Order-1 entropy coding.
        const ORDER = 0x01;
        /// Reserved.
        const RESERVED = 0x02;
        /// Interleave 32 rANS states.
        const N32 = 0x04;
        /// Interleave byte streams.
        const STRIPE = 0x08;
        /// Discard the uncompressed data size.
        const NO_SIZE = 0x10;
        /// Data is uncompressed.
        const CAT = 0x20;
        /// Use run-length encoding.
        const RLE = 0x40;
        /// Use bit packing.
        const PACK = 0x80;
    }
}

impl From<u8> for Flags {
    fn from(n: u8) -> Self {
        Self::from_bits_truncate(n)
    }
}

impl From<Flags> for u8 {
    fn from(flags: Flags) -> Self {
        flags.bits()
    }
}