#[non_exhaustive]pub enum DecodedImage {
Png(PngDecoded),
Jpeg(JpegDecoded),
Bmp(BmpDecoded),
}Expand description
Universal decoded image — union of all per-codec decoded structs.
This enum is #[non_exhaustive] because new codecs (e.g. WebP) may be
added over time. Users should include a wildcard arm when matching.
Each variant wraps the per-codec decoded struct (e.g. png::PngDecoded),
which itself contains the pixel data and ancillary metadata. This means
load() always gives you metadata for free — no separate “with metadata”
function needed.
Per-codec pixel enums (e.g. png::PngImage) are not
#[non_exhaustive] — they are exhaustive spec sheets. If you know the
format, prefer decoding with the per-codec API directly; you get
exhaustive matching and avoid the wildcard arm.
§Examples
let bytes = std::fs::read("image.png").unwrap();
match load(&bytes).unwrap() {
#[cfg(feature = "png")]
DecodedImage::Png(decoded) => {
// `decoded.image` is a `PngImage` — match exhaustively
// `decoded.metadata` carries colour-space info, text chunks, etc.
}
_ => { /* unknown or unsupported codec */ }
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Png(PngDecoded)
png only.A decoded PNG file — pixel data + metadata.
Only available with the png feature.
Jpeg(JpegDecoded)
jpeg only.A decoded JPEG file — pixel data + metadata.
Only available with the jpeg feature.
Bmp(BmpDecoded)
bmp only.A decoded BMP file — pixel data + metadata.
Only available with the bmp feature.
Auto Trait Implementations§
impl Freeze for DecodedImage
impl RefUnwindSafe for DecodedImage
impl Send for DecodedImage
impl Sync for DecodedImage
impl Unpin for DecodedImage
impl UnsafeUnpin for DecodedImage
impl UnwindSafe for DecodedImage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ConvertPixelExt for T
impl<T> ConvertPixelExt for T
Source§impl<T> FromLinear<T> for T
impl<T> FromLinear<T> for T
Source§fn from_linear(acc: T) -> T
fn from_linear(acc: T) -> T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more