Skip to main content

Decoder

Trait Decoder 

Source
pub trait Decoder: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn open<'a>(
        &'a self,
        request: &'a OpenRequest,
    ) -> Decoding<'a, Result<Box<dyn FrameReader>, OpenError>>;
}
Expand description

Decoder is one codec library, such as Apple’s ImageIO or the portable image crate.

A loader tries its decoders in registration order and the first one that opens the bytes owns them for every frame. A decoder is a stateless registry shared across threads; the FrameReader it opens is per image and stays on the thread that opened it, so a reader may hold thread-affine platform objects.

Required Methods§

Source

fn name(&self) -> &'static str

name identifies this decoder in diagnostics when every decoder declines an image.

Source

fn open<'a>( &'a self, request: &'a OpenRequest, ) -> Decoding<'a, Result<Box<dyn FrameReader>, OpenError>>

open reads enough of the bytes to know the image’s size and frame count.

Return OpenError::Unsupported for a format or variant this decoder does not read, so the next decoder gets its turn. Anything else stops the search.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§