Skip to main content

IncrementalDecoder

Struct IncrementalDecoder 

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

A push-based decoder for any still WebP or animation.

Dispatches on the container kind: lossless stills and all animations stream through [crate::lossless], a bare lossy VP8 still row-streams through [crate::lossy], and an extended lossy still (which may carry ALPH alpha) is buffered and finished with a one-shot decode. The pixels and error semantics match decode exactly; the only new streaming capability over the lossless/animation paths is the bare lossy still. Read-free, so it works on no_std + alloc.

Implementations§

Source§

impl IncrementalDecoder

Source

pub fn new() -> Self

A new decoder with default options.

Source

pub const fn with_options(options: DecodeOptions) -> Self

A new decoder with the given options (output layout, per-image pixel limit).

Source

pub fn push(&mut self, chunk: &[u8]) -> Result<Progress>

Feed the next slice of the file and report Progress.

§Errors

The same errors as decode, surfaced as soon as the buffered bytes make them detectable.

Source

pub fn frame_image(&self) -> Option<&Image>

The most-recently composited animation frame, or None for a still image. Mirrors the underlying decoder’s frame_image.

Source

pub fn drain_rows(&mut self) -> Option<RowDrain<'_>>

Borrow the finalized-but-not-yet-viewed rows of a streamed still image (a non-consuming early view). None unless a row-streaming back end is active (a lossless or bare-lossy still); the deferred and animation paths yield no rows.

Source

pub fn into_image(self) -> Result<Image>

Retrieve the complete decoded image (an animation’s first composited frame) once Progress::Finished has been reported.

§Errors

The same errors as decode when the buffer is not a fully-decoded image.

Trait Implementations§

Source§

impl Default for IncrementalDecoder

Available on crate feature alloc only.
Source§

fn default() -> Self

Returns the “default value” for a type. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.