Skip to main content

Decoder

Trait Decoder 

Source
pub trait Decoder<T, C>{
    // Required method
    fn decode(&self, bytes: &[u8]) -> Result<Image<T, C>>;

    // Provided method
    fn decode_file<P: AsRef<Path>>(&self, filename: P) -> Result<Image<T, C>> { ... }
}
Expand description

Trait for an image decoder, use this to get an image from a byte stream

Required Methods§

Source

fn decode(&self, bytes: &[u8]) -> Result<Image<T, C>>

From the bytes decode an image, will perform any scaling or conversions required to represent elements with type T.

Provided Methods§

Source

fn decode_file<P: AsRef<Path>>(&self, filename: P) -> Result<Image<T, C>>

Given a filename decode an image performing any necessary conversions.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T> Decoder<T, RGB> for PpmDecoder

Implements the decoder trait for the PpmDecoder.

The ColourModel type argument is locked to RGB - this prevents calling RGB::into::() unnecessarily which is unavoidable until trait specialisation is stabilised.