Skip to main content

atx_reader/
error.rs

1use thiserror::Error;
2
3/// Errors produced while parsing or decoding a `.atx` file.
4#[derive(Debug, Error)]
5pub enum AtxError {
6    #[error("input too short: needed at least {needed} bytes, got {got}")]
7    TooShort { needed: usize, got: usize },
8
9    #[error("not an AAPL container (expected magic `AAPL\\r\\n\\x1a\\n`)")]
10    BadMagic,
11
12    #[error("chunk `{tag}` is malformed or truncated at offset 0x{offset:x}")]
13    BadChunk { tag: String, offset: usize },
14
15    #[error("required chunk `{0}` not found in container")]
16    ChunkNotFound(&'static str),
17
18    #[error("no texture payload found (neither `astc` nor `LZFS` chunk)")]
19    PayloadNotFound,
20
21    #[error("ASTC decode failed: {0}")]
22    AstcDecode(String),
23
24    #[error("LZFSE decompression failed: {0}")]
25    LzfseDecode(String),
26
27    #[error("LZFSE support not enabled (rebuild with feature `lzfse`)")]
28    LzfseUnavailable,
29
30    #[error("io error: {0}")]
31    Io(#[from] std::io::Error),
32}
33
34pub type Result<T> = core::result::Result<T, AtxError>;