1pub type Result<T, E = Error> = std::result::Result<T, E>;
5
6#[derive(Debug)]
7pub enum Error {
8 Io(std::io::Error),
9 NotFound(String),
10 Library(libloading::Error),
11 JpegEncoding(jpeg_encoder::EncodingError),
12 JpegDecoding(zune_jpeg::errors::DecodeErrors),
13 PngDecoding(zune_png::error::PngDecodeErrors),
14 ResizeImageBuffer(fast_image_resize::ImageBufferError),
15 Resize(fast_image_resize::ResizeError),
16 Yuv(yuv::YuvError),
17 #[cfg(target_os = "linux")]
18 G2D(g2d_sys::Error),
19 Tensor(edgefirst_tensor::Error),
20 NotImplemented(String),
21 NotSupported(String),
22 InvalidShape(String),
23 #[cfg(target_os = "linux")]
24 #[cfg(feature = "opengl")]
25 EGL(khronos_egl::Error),
26 GLVersion(String),
27 #[cfg(target_os = "linux")]
28 #[cfg(feature = "opengl")]
29 EGLLoad(khronos_egl::LoadError<libloading::Error>),
30 #[cfg(target_os = "linux")]
31 #[cfg(feature = "opengl")]
32 GbmInvalidFd(gbm::InvalidFdError),
33 #[cfg(target_os = "linux")]
34 #[cfg(feature = "opengl")]
35 GbmFrontBuffer(gbm::FrontBufferError),
36 OpenGl(String),
37 Internal(String),
38 CropInvalid(String),
39 ForcedBackendUnavailable(String),
40 NoConverter,
41}
42
43impl From<std::io::Error> for Error {
44 fn from(err: std::io::Error) -> Self {
45 Error::Io(err)
46 }
47}
48
49impl From<libloading::Error> for Error {
50 fn from(err: libloading::Error) -> Self {
51 Error::Library(err)
52 }
53}
54
55impl From<jpeg_encoder::EncodingError> for Error {
56 fn from(err: jpeg_encoder::EncodingError) -> Self {
57 Error::JpegEncoding(err)
58 }
59}
60
61impl From<zune_jpeg::errors::DecodeErrors> for Error {
62 fn from(err: zune_jpeg::errors::DecodeErrors) -> Self {
63 Error::JpegDecoding(err)
64 }
65}
66
67impl From<zune_png::error::PngDecodeErrors> for Error {
68 fn from(err: zune_png::error::PngDecodeErrors) -> Self {
69 Error::PngDecoding(err)
70 }
71}
72
73impl From<fast_image_resize::ImageBufferError> for Error {
74 fn from(err: fast_image_resize::ImageBufferError) -> Self {
75 Error::ResizeImageBuffer(err)
76 }
77}
78
79impl From<fast_image_resize::ResizeError> for Error {
80 fn from(err: fast_image_resize::ResizeError) -> Self {
81 Error::Resize(err)
82 }
83}
84
85impl From<yuv::YuvError> for Error {
86 fn from(err: yuv::YuvError) -> Self {
87 Error::Yuv(err)
88 }
89}
90
91#[cfg(target_os = "linux")]
92impl From<g2d_sys::Error> for Error {
93 fn from(err: g2d_sys::Error) -> Self {
94 Error::G2D(err)
95 }
96}
97
98impl From<edgefirst_tensor::Error> for Error {
99 fn from(err: edgefirst_tensor::Error) -> Self {
100 Error::Tensor(err)
101 }
102}
103
104#[cfg(target_os = "linux")]
105#[cfg(feature = "opengl")]
106impl From<khronos_egl::Error> for Error {
107 fn from(err: khronos_egl::Error) -> Self {
108 Error::EGL(err)
109 }
110}
111
112#[cfg(target_os = "linux")]
113#[cfg(feature = "opengl")]
114impl From<khronos_egl::LoadError<libloading::Error>> for Error {
115 fn from(err: khronos_egl::LoadError<libloading::Error>) -> Self {
116 Error::EGLLoad(err)
117 }
118}
119
120#[cfg(target_os = "linux")]
121#[cfg(feature = "opengl")]
122impl From<gbm::InvalidFdError> for Error {
123 fn from(err: gbm::InvalidFdError) -> Self {
124 Error::GbmInvalidFd(err)
125 }
126}
127
128#[cfg(target_os = "linux")]
129#[cfg(feature = "opengl")]
130impl From<gbm::FrontBufferError> for Error {
131 fn from(err: gbm::FrontBufferError) -> Self {
132 Error::GbmFrontBuffer(err)
133 }
134}
135
136#[cfg(target_os = "linux")]
137#[cfg(feature = "opengl")]
138impl From<gls::Error> for Error {
139 fn from(err: gls::Error) -> Self {
140 Error::OpenGl(err.to_string())
141 }
142}
143
144impl From<ndarray::ShapeError> for Error {
145 fn from(err: ndarray::ShapeError) -> Self {
146 Error::Internal(format!("{err}"))
147 }
148}
149
150impl From<fast_image_resize::CropBoxError> for Error {
151 fn from(err: fast_image_resize::CropBoxError) -> Self {
152 Error::Internal(format!("{err}"))
153 }
154}
155
156impl std::fmt::Display for Error {
157 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
158 write!(f, "{self:?}")
159 }
160}
161
162impl std::error::Error for Error {}