use std::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CompressedMeshError {
InvalidMagic,
UnsupportedVersion,
UnsupportedFlags,
InvalidIndexWidth,
InvalidCount,
InvalidBounds,
InvalidPayloadLength,
PayloadTooShort,
TrailingData,
IndexOutOfBounds,
IntegerOverflow,
}
impl fmt::Display for CompressedMeshError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let message = match self {
Self::InvalidMagic => "compressed mesh magic bytes are invalid",
Self::UnsupportedVersion => "compressed mesh version is unsupported",
Self::UnsupportedFlags => "compressed mesh reserved flags are non-zero",
Self::InvalidIndexWidth => "compressed mesh index width is invalid",
Self::InvalidCount => "compressed mesh count is invalid",
Self::InvalidBounds => "compressed mesh quantization bounds are invalid",
Self::InvalidPayloadLength => "compressed mesh payload length is invalid",
Self::PayloadTooShort => "compressed mesh payload is shorter than declared",
Self::TrailingData => "compressed mesh payload has trailing bytes",
Self::IndexOutOfBounds => "compressed mesh index is out of bounds",
Self::IntegerOverflow => "compressed mesh offset calculation overflowed",
};
f.write_str(message)
}
}
impl std::error::Error for CompressedMeshError {}