| 1 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::Infalliblerust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Infallible#; |
| 2 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::{selfrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#}; |
| 3 | |
| 4 | use craterust-analyzer cargo qoi 0.4.1 crate/::constsrust-analyzer cargo qoi 0.4.1 consts/::QOI_MAGICrust-analyzer cargo qoi 0.4.1 consts/QOI_MAGIC.; |
| 5 | |
| 6 | /// Errors that can occur during encoding or decoding. |
| 7 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 8 | pub enum Errorrust-analyzer cargo qoi 0.4.1 error/Error# { |
| 9 | /// Leading 4 magic bytes don't match when decoding |
| 10 | InvalidMagicrust-analyzer cargo qoi 0.4.1 error/Error#InvalidMagic# { magicrust-analyzer cargo qoi 0.4.1 error/Error#InvalidMagic#magic.: u32 }, |
| 11 | /// Invalid number of channels: expected 3 or 4 |
| 12 | InvalidChannelsrust-analyzer cargo qoi 0.4.1 error/Error#InvalidChannels# { channelsrust-analyzer cargo qoi 0.4.1 error/Error#InvalidChannels#channels.: u8 }, |
| 13 | /// Invalid color space: expected 0 or 1 |
| 14 | InvalidColorSpacerust-analyzer cargo qoi 0.4.1 error/Error#InvalidColorSpace# { colorspacerust-analyzer cargo qoi 0.4.1 error/Error#InvalidColorSpace#colorspace.: u8 }, |
| 15 | /// Invalid image dimensions: can't be empty or larger than 400Mp |
| 16 | InvalidImageDimensionsrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageDimensions# { widthrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageDimensions#width.: u32, heightrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageDimensions#height.: u32 }, |
| 17 | /// Image dimensions are inconsistent with image buffer length |
| 18 | InvalidImageLengthrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageLength# { sizerust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageLength#size.: usize, widthrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageLength#width.: u32, heightrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageLength#height.: u32 }, |
| 19 | /// Output buffer is too small to fit encoded/decoded image |
| 20 | OutputBufferTooSmallrust-analyzer cargo qoi 0.4.1 error/Error#OutputBufferTooSmall# { sizerust-analyzer cargo qoi 0.4.1 error/Error#OutputBufferTooSmall#size.: usize, requiredrust-analyzer cargo qoi 0.4.1 error/Error#OutputBufferTooSmall#required.: usize }, |
| 21 | /// Input buffer ended unexpectedly before decoding was finished |
| 22 | UnexpectedBufferEndrust-analyzer cargo qoi 0.4.1 error/Error#UnexpectedBufferEnd#, |
| 23 | /// Invalid stream end marker encountered when decoding |
| 24 | InvalidPaddingrust-analyzer cargo qoi 0.4.1 error/Error#InvalidPadding#, |
| 25 | #[cfg(feature = "std")] |
| 26 | /// Generic I/O error from the wrapped reader/writer |
| 27 | IoErrorrust-analyzer cargo qoi 0.4.1 error/Error#IoError#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#), |
| 28 | } |
| 29 | |
| 30 | /// Alias for [`Result`](std::result::Result) with the error type of [`Error`]. |
| 31 | pub type Resultrust-analyzer cargo qoi 0.4.1 error/Result#<T> = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, Errorrust-analyzer cargo qoi 0.4.1 error/Error#>; |
| 32 | |
| 33 | impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Errorrust-analyzer cargo qoi 0.4.1 error/Error# { |
| 34 | fn fmtrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 35 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 36 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::InvalidMagicrust-analyzer cargo qoi 0.4.1 error/Error#InvalidMagic# { magicrust-analyzer cargo qoi 0.4.1 error/Error#InvalidMagic#magic. } => { |
| 37 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "invalid magic: expected {:?}, got {:?}", QOI_MAGICrust-analyzer cargo qoi 0.4.1 consts/QOI_MAGIC., magic.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be_bytes().()) |
| 38 | } |
| 39 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::InvalidChannelsrust-analyzer cargo qoi 0.4.1 error/Error#InvalidChannels# { channelsrust-analyzer cargo qoi 0.4.1 error/Error#InvalidChannels#channels. } => { |
| 40 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "invalid number of channels: {}", channels) |
| 41 | } |
| 42 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::InvalidColorSpacerust-analyzer cargo qoi 0.4.1 error/Error#InvalidColorSpace# { colorspacerust-analyzer cargo qoi 0.4.1 error/Error#InvalidColorSpace#colorspace. } => { |
| 43 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "invalid color space: {} (expected 0 or 1)", colorspace) |
| 44 | } |
| 45 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::InvalidImageDimensionsrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageDimensions# { widthrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageDimensions#width., heightrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageDimensions#height. } => { |
| 46 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "invalid image dimensions: {}x{}", width, height) |
| 47 | } |
| 48 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::InvalidImageLengthrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageLength# { sizerust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageLength#size., widthrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageLength#width., heightrust-analyzer cargo qoi 0.4.1 error/Error#InvalidImageLength#height. } => { |
| 49 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "invalid image length: {} bytes for {}x{}", size, width, height) |
| 50 | } |
| 51 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::OutputBufferTooSmallrust-analyzer cargo qoi 0.4.1 error/Error#OutputBufferTooSmall# { sizerust-analyzer cargo qoi 0.4.1 error/Error#OutputBufferTooSmall#size., requiredrust-analyzer cargo qoi 0.4.1 error/Error#OutputBufferTooSmall#required. } => { |
| 52 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "output buffer size too small: {} (required: {})", size, required) |
| 53 | } |
| 54 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::UnexpectedBufferEndrust-analyzer cargo qoi 0.4.1 error/Error#UnexpectedBufferEnd# => { |
| 55 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "unexpected input buffer end while decoding") |
| 56 | } |
| 57 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::InvalidPaddingrust-analyzer cargo qoi 0.4.1 error/Error#InvalidPadding# => { |
| 58 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "invalid padding (stream end marker mismatch)") |
| 59 | } |
| 60 | #[cfg(feature = "std")] |
| 61 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][Display]::IoErrorrust-analyzer cargo qoi 0.4.1 error/Error#IoError#(ref err) => { |
| 62 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "i/o error: {}", err) |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | #[cfg(feature = "std")] |
| 69 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for Errorrust-analyzer cargo qoi 0.4.1 error/Error# {} |
| 70 | |
| 71 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Infalliblerust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Infallible#> for Errorrust-analyzer cargo qoi 0.4.1 error/Error# { |
| 72 | fn fromrust-analyzer cargo qoi 0.4.1 error/impl#[Error][`From<Infallible>`]from().(_: Infalliblerust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Infallible#) -> Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][`From<Infallible>`] { |
| 73 | unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!() |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | #[cfg(feature = "std")] |
| 78 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> for Errorrust-analyzer cargo qoi 0.4.1 error/Error# { |
| 79 | fn fromrust-analyzer cargo qoi 0.4.1 error/impl#[Error][`From<alloc::io::Error>`]from().(err: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) -> Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][`From<alloc::io::Error>`] { |
| 80 | Selfrust-analyzer cargo qoi 0.4.1 error/impl#[Error][`From<alloc::io::Error>`]::IoErrorrust-analyzer cargo qoi 0.4.1 error/Error#IoError#(err) |
| 81 | } |
| 82 | } |