Skip to main content

AnimationDecoder

Struct AnimationDecoder 

Source
pub struct AnimationDecoder { /* private fields */ }
Expand description

Stateful decoder for exactly one stored animation sequence.

Implementations§

Source§

impl AnimationDecoder

Source

pub fn new(input: &[u8], limits: DecodeLimits) -> Result<Self, DecodeError>

Creates a decoder for one stored animated WebP sequence.

The input bytes are copied so the returned decoder owns the data needed by libwebp. Frames are returned as composited, full-canvas RGBA buffers. The decoder does not replay the sequence according to its loop count.

Source

pub fn info(&self) -> &AnimationInfo

Returns metadata for the stored animation sequence.

Source

pub fn frame_durations(&self) -> Result<Vec<Duration>, DecodeError>

Returns one source display duration per stored frame, in frame order.

This reads animation-container metadata only: it does not decode RGBA pixels or advance the sequential decoder. The configured total-duration limit is applied and may cause this method to return an error.

Source

pub fn reset(&mut self)

Resets this decoder to the first frame of its stored animation sequence.

The decoder, input allocation, immutable metadata, and configured limits are preserved; only libwebp’s sequence state and this wrapper’s timing accumulator are reset. This is a sequence reset, not a random-seek operation; the next Self::next_frame call starts at the first stored frame.

Source

pub fn has_more_frames(&self) -> bool

Returns whether unread frames remain in the stored sequence.

Source

pub fn next_frame(&mut self) -> Result<Option<AnimationFrame>, DecodeError>

Returns None only after every frame in the stored sequence was read.

Trait Implementations§

Source§

impl Drop for AnimationDecoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.