1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum FormatError {
8 BadMagic,
10 UnsupportedVersion,
12 Truncated,
14 Unaligned,
16 InvalidNodeIndex,
18 InvalidFeatureIndex,
20 MisalignedTreeOffset,
22}
23
24impl core::fmt::Display for FormatError {
25 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26 match self {
27 FormatError::BadMagic => write!(f, "bad magic: expected \"IRIT\""),
28 FormatError::UnsupportedVersion => write!(f, "unsupported format version"),
29 FormatError::Truncated => write!(f, "buffer truncated"),
30 FormatError::Unaligned => write!(f, "buffer not 4-byte aligned"),
31 FormatError::InvalidNodeIndex => write!(f, "node child index out of bounds"),
32 FormatError::InvalidFeatureIndex => write!(f, "feature index exceeds n_features"),
33 FormatError::MisalignedTreeOffset => {
34 write!(f, "tree offset not aligned to node size")
35 }
36 }
37 }
38}