[][src]Struct compu::decompressor::memory::Decompressor

pub struct Decompressor<D> { /* fields omitted */ }

Decompressor

It stores decompressed data in its internal buffer. Once push returns DecoderResult::Finished or DecoderResult::Error, it it no longer expected to accept new input. Result can be retrieved using output or take.

Usage

use compu::decoder::{Decoder, DecoderResult, BrotliDecoder};

let data = vec![5; 5];
let mut decoder = compu::decompressor::memory::Decompressor::new(BrotliDecoder::default());

let result = decoder.push(&data);

assert_eq!(result, DecoderResult::Finished);

Methods

impl<D: Decoder> Decompressor<D>[src]

pub fn new(decoder: D) -> Self[src]

Creates new instance

pub fn with_capacity(capacity: usize, decoder: D) -> Self[src]

Creates new instance with provided capacity

pub fn decoder(&self) -> &D[src]

Returns reference to underlying decoder

pub fn push(&mut self, data: &[u8]) -> DecoderResult[src]

Pushes data into, and returns Decoder's operation status

  • DecoderResult::Finished indicates decompression has finished successfully.
  • DecoderResult::NeedInput indicates that further data is necessary.
  • DecoderResult::NeedOutput SHOULD not happen

Any other variants indicates error.

pub fn output<'a>(&'a self) -> &'a [u8][src]

Returns slice of currently decompressed data

pub fn consume_output<'a>(&'a mut self) -> &'a [u8][src]

Returns slice of currently decompressed data and marks it as consumed

After calling this function, the underlying buffer basically sets length equal to 0 allowing to overwrite already written data with further pushes.

pub fn take(self) -> Vec<u8>[src]

Consumes self and returns underlying data.

Auto Trait Implementations

impl<D> Send for Decompressor<D> where
    D: Send

impl<D> Sync for Decompressor<D> where
    D: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]