ktx2/
error.rs

1use core::fmt;
2#[cfg(feature = "std")]
3use std::error::Error;
4
5/// Error, that happend when data doesn't satisfy expected parameters.
6#[derive(Debug)]
7#[non_exhaustive]
8pub enum ParseError {
9    /// Unexpected magic numbers
10    BadMagic,
11    /// Zero pixel width
12    ZeroWidth,
13    /// Zero face count
14    ZeroFaceCount,
15    /// Unexpected end of buffer
16    UnexpectedEnd,
17}
18
19#[cfg(feature = "std")]
20impl Error for ParseError {}
21
22impl fmt::Display for ParseError {
23    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
24        match &self {
25            ParseError::BadMagic => f.pad("unexpected magic numbers"),
26            ParseError::ZeroWidth => f.pad("zero pixel width"),
27            ParseError::ZeroFaceCount => f.pad("zero face count"),
28            ParseError::UnexpectedEnd => f.pad("unexpected end of buffer"),
29        }
30    }
31}