Skip to main content

Decompressor

Struct Decompressor 

Source
pub struct Decompressor(/* private fields */);
Expand description

The streaming decompressor of DecompressionStream, for host code such as an HTTP client that decodes a Content-Encoding.

Write input, then read output until read returns None before writing again; after finish, reads return the rest and fail if the compressed stream ended early. Each read returns at most 64 KiB, so a small input never inflates into one large buffer, and the decompressed bytes in all count toward limit, failing with LimitExceeded past it. Data after the end of the stream, invalid data and a gzip checksum that does not match fail with InvalidRequest.

Implementations§

Source§

impl Decompressor

Source

pub fn new(format: CompressionFormat, limit: Option<usize>) -> Self

Source

pub fn write(&mut self, bytes: &[u8]) -> Result<()>

Add compressed input. Fails while output of the previous write is still to be read.

Source

pub fn finish(&mut self)

Mark the end of the compressed input.

Source

pub fn read(&mut self) -> Result<Option<Vec<u8>>>

The next piece of output, or None until more input arrives, or, after finish, once the stream is complete.

Trait Implementations§

Source§

impl Debug for Decompressor

Source§

fn fmt(&self, formatter: &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> Same for T

Source§

type Output = T

Should always be Self
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.