Add docstrings for Error variants

This commit is contained in:
Ivan Smirnov 2022-01-03 22:10:03 +03:00
parent d9bf3db32c
commit b0dca7ba02

View file

@ -6,31 +6,24 @@ use crate::consts::QOI_MAGIC;
/// Errors that can occur during encoding or decoding. /// Errors that can occur during encoding or decoding.
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
InvalidMagic { /// Leading 4 magic bytes don't match when decoding
magic: u32, InvalidMagic { magic: u32 },
}, /// Invalid number of channels: expected 3 or 4
InvalidChannels { InvalidChannels { channels: u8 },
channels: u8, /// Invalid color space: expected 0 or 1
}, InvalidColorSpace { colorspace: u8 },
InvalidColorSpace { /// Invalid image dimensions: can't be empty or larger than 400Mp
colorspace: u8, InvalidImageDimensions { width: u32, height: u32 },
}, /// Image dimensions are inconsistent with image buffer length
InvalidImageDimensions { InvalidImageLength { size: usize, width: u32, height: u32 },
width: u32, /// Output buffer is too small to fit encoded/decoded image
height: u32, OutputBufferTooSmall { size: usize, required: usize },
}, /// Input buffer ended unexpectedly before decoding was finished
InvalidImageLength {
size: usize,
width: u32,
height: u32,
},
OutputBufferTooSmall {
size: usize,
required: usize,
},
UnexpectedBufferEnd, UnexpectedBufferEnd,
/// Invalid stream end marker encountered when decoding
InvalidPadding, InvalidPadding,
#[cfg(feature = "std")] #[cfg(feature = "std")]
/// Generic I/O error from the wrapped reader/writer
IoError(std::io::Error), IoError(std::io::Error),
} }