Skip to main content

LzwDecoder

Struct LzwDecoder 

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

Decompresses an LZW stream.

Implementations§

Source§

impl LzwDecoder

Source

pub fn new(order: BitOrder, minimum_width: u32) -> Result<Self>

A decoder for order, with minimum_width bits per initial code.

GIF carries the minimum width in the image block; TIFF fixes it at 8.

§Errors

Returns Error if minimum_width is outside 2..=11. A width of 1 has no room for both the clear and end codes, and 12 leaves none for the table.

Source

pub fn gif(minimum_width: u32) -> Result<Self>

A decoder for GIF’s dialect at minimum_width.

§Errors

As LzwDecoder::new.

Source

pub const fn tiff() -> Self

A decoder for TIFF’s dialect, whose minimum width is always 8.

Source

pub fn decode(&self, data: &[u8], limit: usize) -> Result<Vec<u8>>

Decompress data, refusing to produce more than limit bytes.

The bound is what makes a decompression bomb a malformed-input error rather than an allocation the caller has to survive: LZW expands by up to 4096:1, so a caller states what it is prepared to accept.

§Errors

Returns Error for an invalid code, a stream that ends mid-symbol without an end code, or output exceeding limit.

Trait Implementations§

Source§

impl Debug for LzwDecoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.