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 NoConverter,
40}
41
42impl From<std::io::Error> for Error {
43 fn from(err: std::io::Error) -> Self {
44 Error::Io(err)
45 }
46}
47
48impl From<libloading::Error> for Error {
49 fn from(err: libloading::Error) -> Self {
50 Error::Library(err)
51 }
52}
53
54impl From<jpeg_encoder::EncodingError> for Error {
55 fn from(err: jpeg_encoder::EncodingError) -> Self {
56 Error::JpegEncoding(err)
57 }
58}
59
60impl From<zune_jpeg::errors::DecodeErrors> for Error {
61 fn from(err: zune_jpeg::errors::DecodeErrors) -> Self {
62 Error::JpegDecoding(err)
63 }
64}
65
66impl From<zune_png::error::PngDecodeErrors> for Error {
67 fn from(err: zune_png::error::PngDecodeErrors) -> Self {
68 Error::PngDecoding(err)
69 }
70}
71
72impl From<fast_image_resize::ImageBufferError> for Error {
73 fn from(err: fast_image_resize::ImageBufferError) -> Self {
74 Error::ResizeImageBuffer(err)
75 }
76}
77
78impl From<fast_image_resize::ResizeError> for Error {
79 fn from(err: fast_image_resize::ResizeError) -> Self {
80 Error::Resize(err)
81 }
82}
83
84impl From<yuv::YuvError> for Error {
85 fn from(err: yuv::YuvError) -> Self {
86 Error::Yuv(err)
87 }
88}
89
90#[cfg(target_os = "linux")]
91impl From<g2d_sys::Error> for Error {
92 fn from(err: g2d_sys::Error) -> Self {
93 Error::G2D(err)
94 }
95}
96
97impl From<edgefirst_tensor::Error> for Error {
98 fn from(err: edgefirst_tensor::Error) -> Self {
99 Error::Tensor(err)
100 }
101}
102
103#[cfg(target_os = "linux")]
104#[cfg(feature = "opengl")]
105impl From<khronos_egl::Error> for Error {
106 fn from(err: khronos_egl::Error) -> Self {
107 Error::EGL(err)
108 }
109}
110
111#[cfg(target_os = "linux")]
112#[cfg(feature = "opengl")]
113impl From<khronos_egl::LoadError<libloading::Error>> for Error {
114 fn from(err: khronos_egl::LoadError<libloading::Error>) -> Self {
115 Error::EGLLoad(err)
116 }
117}
118
119#[cfg(target_os = "linux")]
120#[cfg(feature = "opengl")]
121impl From<gbm::InvalidFdError> for Error {
122 fn from(err: gbm::InvalidFdError) -> Self {
123 Error::GbmInvalidFd(err)
124 }
125}
126
127#[cfg(target_os = "linux")]
128#[cfg(feature = "opengl")]
129impl From<gbm::FrontBufferError> for Error {
130 fn from(err: gbm::FrontBufferError) -> Self {
131 Error::GbmFrontBuffer(err)
132 }
133}
134
135#[cfg(target_os = "linux")]
136#[cfg(feature = "opengl")]
137impl From<gls::Error> for Error {
138 fn from(err: gls::Error) -> Self {
139 Error::OpenGl(err.to_string())
140 }
141}
142
143impl From<ndarray::ShapeError> for Error {
144 fn from(err: ndarray::ShapeError) -> Self {
145 Error::Internal(format!("{err}"))
146 }
147}
148
149impl From<fast_image_resize::CropBoxError> for Error {
150 fn from(err: fast_image_resize::CropBoxError) -> Self {
151 Error::Internal(format!("{err}"))
152 }
153}
154
155impl std::fmt::Display for Error {
156 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
157 write!(f, "{self:?}")
158 }
159}
160
161impl std::error::Error for Error {}