ici_files/
errors.rs

1use std::string::FromUtf8Error;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum IndexedImageError {
6    #[error("Invalid file header")]
7    NotIciFile,
8    #[error("Unsupported ICI version {0}")]
9    UnknownIciVersion(u8),
10    #[error("Palette name must have at least 1 character")]
11    PaletteNameTooShort,
12    #[error("Palette name has more than 255 character")]
13    PaletteNameTooLong,
14    #[error("Palette has more than 255 colors")]
15    PaletteTooManyColors,
16    #[error("Image requires a palette with at least {0} colors")]
17    PaletteTooFewColors(u8),
18    #[error("Invalid file format/contents at {0}: {1}")]
19    InvalidFileFormat(usize, String),
20    #[error("Palette name was not valid UTF-8")]
21    PaletteNameNotUtf8(#[from] FromUtf8Error),
22    #[error("ID was greater than palette size")]
23    IdOutsideOfNewPalette,
24    #[error("Index {0} was outside of {2} (len {1})")]
25    IndexOutOfRange(usize, usize, &'static str),
26    #[error("Image width is 0")]
27    WidthIsZero,
28    #[error("Image height is 0")]
29    HeightIsZero,
30    #[error("Missing pixels data, count: {0} expected: {1}")]
31    MissingData(usize, usize),
32    #[error("Palette is empty")]
33    PaletteIsEmpty,
34    #[error("Per frame timing is negative: {0}")]
35    NegativePerFrame(f64),
36    #[error("Image after scaling would be too big {0}x{1}")]
37    TooBigPostScale(usize, usize),
38    #[error("Scale params must be > 0, was {0},{1}")]
39    InvalidScaleParams(usize, usize),
40    #[error("Both image must be the same size")]
41    InvalidImageSize,
42    #[error("Color diff list must be the same size as the image palette")]
43    InvalidPaletteSize,
44    #[error("Hex string has invalid format: {0}")]
45    InvalidHexFormat(String),
46}