Skip to main content

draco_oxide_core/codec/
mod.rs

1pub mod connectivity;
2
3pub mod attribute;
4
5pub mod entropy;
6
7pub mod header {
8    use crate::bit_coder::{ByteReader, ByteWriter, ReaderErr};
9
10    #[derive(Debug, Clone, Copy, PartialEq)]
11    pub enum EncoderMethod {
12        Edgebreaker,
13        #[allow(unused)]
14        Sequential,
15    }
16
17    impl EncoderMethod {
18        #[inline]
19        #[allow(unused)]
20        pub fn read_from<R>(reader: &mut R) -> Result<Self, ReaderErr>
21        where
22            R: ByteReader,
23        {
24            match reader.read_u8()? {
25                0 => Ok(EncoderMethod::Sequential),
26                1 => Ok(EncoderMethod::Edgebreaker),
27                _ => panic!("Unknown encoder method ID"),
28            }
29        }
30
31        #[inline]
32        pub fn write_to<W>(self, writer: &mut W)
33        where
34            W: ByteWriter,
35        {
36            match self {
37                EncoderMethod::Sequential => writer.write_u8(0),
38                EncoderMethod::Edgebreaker => writer.write_u8(1),
39            }
40        }
41    }
42}