devela/media/image/sixel/
error.rs

1// devela::media::image::sixel::error
2
3use devela::Error;
4
5/// A sixel-related result.
6pub(crate) type SixelResult<T> = Result<T, SixelError>;
7
8/// A sixel-related error.
9#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
10pub enum SixelError {
11    /// Bad argument detected.
12    BadArgument,
13    /// Bad input detected.
14    BadInput,
15    /// Integer overflow.
16    BadIntegerOverflow,
17}
18
19mod _core_impls {
20    use super::{Error, SixelError};
21    use core::fmt;
22
23    impl Error for SixelError {}
24
25    impl fmt::Display for SixelError {
26        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27            match self {
28                SixelError::BadArgument => write!(f, "bad argument detected"),
29                SixelError::BadInput => write!(f, "bad input detected"),
30                SixelError::BadIntegerOverflow => write!(f, "integer overflow"),
31            }
32        }
33    }
34}