pub enum DecodeError {
Show 24 variants
InvalidSignature,
UnexpectedEof,
ChunkTooLong {
length: u32,
},
InvalidChunkType(ChunkType),
CrcMismatch {
chunk: ChunkType,
stored: u32,
computed: u32,
},
MissingHeader,
InvalidChunkLength {
chunk: ChunkType,
length: usize,
},
InvalidDimensions {
width: u32,
height: u32,
},
InvalidFormat {
color_type: u8,
bit_depth: u8,
},
UnsupportedCompressionMethod(u8),
UnsupportedFilterMethod(u8),
UnsupportedInterlaceMethod(u8),
DuplicateChunk(ChunkType),
ChunkOutOfOrder(ChunkType),
UnknownCriticalChunk(ChunkType),
MissingPalette,
InvalidPalette {
length: usize,
},
UnexpectedPalette,
InvalidTransparency,
MissingImageData,
ImageTooLarge {
limit: usize,
},
Zlib(ZlibError),
ImageDataTooShort {
expected: usize,
actual: usize,
},
InvalidFilterType(u8),
}Expand description
An error found while decoding a PNG file.
Variants§
InvalidSignature
The data does not start with the PNG signature.
UnexpectedEof
The data ended inside a chunk or before the IEND chunk.
ChunkTooLong
A chunk declares a length above 2^31 − 1.
InvalidChunkType(ChunkType)
A chunk type contains bytes other than ASCII letters.
CrcMismatch
A chunk’s CRC does not match its contents.
Fields
MissingHeader
The first chunk is not IHDR.
InvalidChunkLength
A chunk with a fixed layout has the wrong length.
InvalidDimensions
Width or height is zero or above 2^31 − 1.
InvalidFormat
The colour type / bit depth pair is not allowed by PNG.
UnsupportedCompressionMethod(u8)
The compression method is not 0 (DEFLATE).
UnsupportedFilterMethod(u8)
The filter method is not 0 (adaptive filtering).
UnsupportedInterlaceMethod(u8)
The interlace method is neither 0 (none) nor 1 (Adam7).
DuplicateChunk(ChunkType)
A chunk that may occur only once occurs again.
ChunkOutOfOrder(ChunkType)
A critical chunk appears where it is not allowed, e.g. PLTE after
IDAT, or IDAT chunks that are not consecutive.
UnknownCriticalChunk(ChunkType)
A critical chunk this decoder does not know.
MissingPalette
An indexed image has no PLTE chunk.
InvalidPalette
A palette is empty, larger than 256 entries, or not a whole number of RGB triples.
UnexpectedPalette
A palette appears in a greyscale image.
InvalidTransparency
A tRNS chunk has the wrong size, or appears in an image with an
alpha channel.
MissingImageData
There is no IDAT chunk.
ImageTooLarge
The decoded image would exceed the decoder’s size limit.
Zlib(ZlibError)
The image data is not a valid zlib stream.
ImageDataTooShort
The image data decompresses to fewer bytes than the image needs.
InvalidFilterType(u8)
A scanline uses a filter type other than 0–4.
Trait Implementations§
Source§impl Clone for DecodeError
impl Clone for DecodeError
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
impl Eq for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()