Trait Encoder

Source
pub trait Encoder<T, U, C>
where U: Data<Elem = T>, T: Copy + Clone + Num + NumAssignOps + NumCast + PartialOrd + Display + PixelBound, C: ColourModel,
{ // Required method fn encode(&self, image: &ImageBase<U, C>) -> Vec<u8> ; // Provided method fn encode_file<P: AsRef<Path>>( &self, image: &ImageBase<U, C>, filename: P, ) -> Result<()> { ... } }
Expand description

Trait for an image encoder

Required Methods§

Source

fn encode(&self, image: &ImageBase<U, C>) -> Vec<u8>

Encode an image into a sequence of bytes for the given format

Provided Methods§

Source

fn encode_file<P: AsRef<Path>>( &self, image: &ImageBase<U, C>, filename: P, ) -> Result<()>

Encode an image saving it to the file at filename. This function shouldn’t add an extension preferring the user to do that instead.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, U> Encoder<T, U, RGB> for PpmEncoder

Implements the encoder trait for the PpmEncoder.

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