1use image_webp::DecodingError;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum Error {
6 #[error("{0}")]
7 Unzip(#[from] UnzipError),
8
9 #[error("{0}")]
10 SogParse(#[from] ParseError),
11
12 #[error("{0}")]
13 SogDecode(#[from] DecodeError),
14}
15
16pub type Result<T> = core::result::Result<T, Error>;
17
18#[derive(Debug, thiserror::Error)]
19pub enum UnzipError {
20 #[error("Zip error: {0}")]
21 Unzip(#[from] zip::result::ZipError),
22}
23
24pub type UnzipResult<T> = core::result::Result<T, UnzipError>;
25
26#[derive(thiserror::Error, Debug)]
27pub enum ParseError {
28 #[error("meta.json not found")]
29 MetaJsonNotFound,
30 #[error("meta.json is invalid data: {0}")]
31 InvalidMetaJson(String),
32 #[error("Deserialize error: {0}")]
33 DeserializeMetaJson(#[from] serde_json::Error),
34 #[error("invalid vector data")]
35 ParseVector(String),
36 #[error("invalid codebook length")]
37 ParseCodebook(String),
38 #[error("image file not found: {0}")]
39 ImageNotFound(String),
40}
41
42pub type ParseResult<T> = core::result::Result<T, ParseError>;
43
44#[derive(Debug, thiserror::Error)]
45pub enum DecodeError {
46 #[error("Image not found: {0}")]
47 DecodeImage(#[from] DecodingError),
48 #[error("Invalid size: {0}")]
49 InvalidSize(String),
50 #[error("Invalid data: {0}")]
51 InvalidData(String),
52}
53
54pub type DecodeResult<T> = core::result::Result<T, DecodeError>;