pub trait Decoder<T, C>where
    T: Copy + Clone + FromPrimitive + Num + NumAssignOps + NumCast + PartialOrd + Display + PixelBound,
    C: ColourModel,{
    // 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.

Implementors§

source§

impl<T> Decoder<T, RGB> for PpmDecoderwhere T: Copy + Clone + Num + NumAssignOps + NumCast + PartialOrd + Display + PixelBound + FromPrimitive,

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.