pltrs_codec/tiff/decode/
error.rs1use std::fmt;
4
5#[derive(Clone, Debug, PartialEq, Eq)]
7pub enum DecodeError {
8 NotTiff,
10 NoImage,
12 MissingTag(u16),
14 InvalidTag(u16),
16 UnsupportedLayout,
20 UnsupportedCompression(u16),
22 UnsupportedPredictor(u16),
25 UnsupportedPlanarConfiguration,
27 EmptyImage,
29 TooLarge {
32 width: u32,
34 height: u32,
36 },
37 Truncated,
39 CorruptData,
41}
42
43impl fmt::Display for DecodeError {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 match self {
46 Self::NotTiff => f.write_str("not a TIFF file"),
47 Self::NoImage => f.write_str("the TIFF file has no image"),
48 Self::MissingTag(tag) => write!(f, "the TIFF image lacks tag {tag}"),
49 Self::InvalidTag(tag) => write!(f, "invalid value of TIFF tag {tag}"),
50 Self::UnsupportedLayout => f.write_str("unknown TIFF pixel layout"),
51 Self::UnsupportedCompression(scheme) => {
52 write!(f, "unsupported TIFF compression {scheme}")
53 }
54 Self::UnsupportedPredictor(predictor) => {
55 write!(f, "unsupported TIFF predictor {predictor}")
56 }
57 Self::UnsupportedPlanarConfiguration => {
58 f.write_str("TIFF images with separate sample planes are not supported")
59 }
60 Self::EmptyImage => f.write_str("the TIFF image has no pixels"),
61 Self::TooLarge { width, height } => {
62 write!(f, "a {width} × {height} TIFF image is too large to decode")
63 }
64 Self::Truncated => f.write_str("the TIFF image data lies outside the file"),
65 Self::CorruptData => f.write_str("corrupt TIFF image data"),
66 }
67 }
68}
69
70impl std::error::Error for DecodeError {}