bunny_codec/compressed/
error.rs1use std::fmt;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum CompressedMeshError {
6 InvalidMagic,
8 UnsupportedVersion,
10 UnsupportedFlags,
12 InvalidIndexWidth,
14 InvalidCount,
16 InvalidBounds,
18 InvalidPayloadLength,
20 PayloadTooShort,
22 TrailingData,
24 IndexOutOfBounds,
26 IntegerOverflow,
28}
29
30impl fmt::Display for CompressedMeshError {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 let message = match self {
33 Self::InvalidMagic => "compressed mesh magic bytes are invalid",
34 Self::UnsupportedVersion => "compressed mesh version is unsupported",
35 Self::UnsupportedFlags => "compressed mesh reserved flags are non-zero",
36 Self::InvalidIndexWidth => "compressed mesh index width is invalid",
37 Self::InvalidCount => "compressed mesh count is invalid",
38 Self::InvalidBounds => "compressed mesh quantization bounds are invalid",
39 Self::InvalidPayloadLength => "compressed mesh payload length is invalid",
40 Self::PayloadTooShort => "compressed mesh payload is shorter than declared",
41 Self::TrailingData => "compressed mesh payload has trailing bytes",
42 Self::IndexOutOfBounds => "compressed mesh index is out of bounds",
43 Self::IntegerOverflow => "compressed mesh offset calculation overflowed",
44 };
45 f.write_str(message)
46 }
47}
48
49impl std::error::Error for CompressedMeshError {}