1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::{error::Error, fmt::Display, io};
use image::ImageError;
#[derive(Debug)]
pub enum AtlasError {
ImageError(ImageError),
IoError(io::Error),
PackingError(&'static str),
}
impl Error for AtlasError {}
impl Display for AtlasError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AtlasError::ImageError(err) => {err.fmt(f)}
AtlasError::IoError(err) => {err.fmt(f)}
AtlasError::PackingError(err) => {err.fmt(f)}
}
}
}
impl From<ImageError> for AtlasError {
fn from(err: ImageError) -> AtlasError {
AtlasError::ImageError(err)
}
}
impl From<io::Error> for AtlasError {
fn from(err: io::Error) -> AtlasError {
AtlasError::IoError(err)
}
}