Struct Decoder

pub struct Decoder<R: Read> { /* private fields */ }

GIF decoder. Create DecodeOptions to get started, and call DecodeOptions::read_info.

Implementations

impl<R> Decoder<R> where R: Read,

fn new(reader: R) -> Result<Self, DecodingError>

Create a new decoder with default options.

fn build() -> DecodeOptions

Return a builder that allows configuring limits etc.

fn next_frame_info(&mut self) -> Result<Option<&Frame<'static>>, DecodingError>

Returns the next frame info

fn current_frame_info(&self) -> Option<&Frame<'static>>

Query information about the frame previously advanced with Self::next_frame_info.

Returns None past the end of file.

fn read_next_frame(&mut self) -> Result<Option<&Frame<'static>>, DecodingError>

Reads the next frame from the image.

Do not call Self::next_frame_info beforehand. Deinterlaces the result.

You can also call .into_iter() on the decoder to use it as a regular iterator.

fn read_into_buffer(&mut self, buf: &mut [u8]) -> Result<(), DecodingError>

Reads the data of the current frame into a pre-allocated buffer.

Self::next_frame_info needs to be called beforehand. The length of buf must be at least Self::buffer_size. Deinterlaces the result.

fn fill_buffer(&mut self, buf: &mut [u8]) -> Result<bool, DecodingError>

Reads data of the current frame into a pre-allocated buffer until the buffer has been filled completely.

The buffer length must be an even number of pixels (multiple of 4 if decoding RGBA).

Self::next_frame_info needs to be called beforehand. Returns true if the supplied buffer could be filled completely. Should not be called after false had been returned.

fn buffer_size(&self) -> usize

Output buffer size

fn line_length(&self) -> usize

Line length of the current frame

fn palette(&self) -> Result<&[u8], DecodingError>

Returns the color palette relevant for the frame that has been decoded

fn global_palette(&self) -> Option<&[u8]>

The global color palette

fn width(&self) -> u16

Width of the image

fn height(&self) -> u16

Height of the image

fn xmp_metadata(&self) -> Option<&[u8]>

XMP metadata stored in the image.

fn icc_profile(&self) -> Option<&[u8]>

ICC profile stored in the image.

fn into_inner(self) -> BufReader<R>

Abort decoding and recover the io::Read instance

fn bg_color(&self) -> Option<usize>

Index of the background color in the global palette

In practice this is not used, and the background is always transparent

fn repeat(&self) -> Repeat

Number of loop repetitions

Trait Implementations

impl<R: Read> IntoIterator for Decoder<R>

type Item = Result<Frame<'static>, DecodingError>;
type IntoIter = DecoderIter<R>;
fn into_iter(self) -> Self::IntoIter

Auto Trait Implementations

impl<R> !RefUnwindSafe for Decoder<R>

impl<R> !Sync for Decoder<R>

impl<R> !UnwindSafe for Decoder<R>

impl<R> Freeze for Decoder<R> where ReadDecoder<R>: Freeze,

impl<R> Send for Decoder<R> where ReadDecoder<R>: Send,

impl<R> Unpin for Decoder<R> where ReadDecoder<R>: Unpin,

impl<R> UnsafeUnpin for Decoder<R> where ReadDecoder<R>: UnsafeUnpin,

Blanket Implementations

impl<T> Any for Decoder<R> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Decoder<R> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Decoder<R> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Decoder<R>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for Decoder<R> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Decoder<R> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Decoder<R> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>