1use enough::StopReason;
4
5#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum Error {
9 #[error("AVIF parse error: {0}")]
11 Parse(#[from] zenavif_parse::Error),
12
13 #[error("AV1 decode error {code}: {msg}")]
15 Decode {
16 code: i32,
18 msg: &'static str,
20 },
21
22 #[error("Color conversion error: {0}")]
24 ColorConversion(#[from] yuv::YuvError),
25
26 #[error("AV1 encode error: {0}")]
28 Encode(String),
29
30 #[error("Unsupported: {0}")]
32 Unsupported(&'static str),
33
34 #[error("Image too large: {width}x{height}")]
36 ImageTooLarge {
37 width: u32,
39 height: u32,
41 },
42
43 #[error("Resource limit exceeded: {0}")]
45 ResourceLimit(String),
46
47 #[error("Out of memory")]
49 OutOfMemory,
50
51 #[error("Operation cancelled: {0:?}")]
53 Cancelled(StopReason),
54
55 #[cfg(feature = "zencodec")]
57 #[error(transparent)]
58 UnsupportedOperation(#[from] zencodec::UnsupportedOperation),
59}
60
61impl From<StopReason> for Error {
62 fn from(reason: StopReason) -> Self {
63 Error::Cancelled(reason)
64 }
65}
66
67pub type Result<T, E = whereat::At<Error>> = core::result::Result<T, E>;