texture_atlasser/
error.rs

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