[−][src]Struct compu::decompressor::memory::Decompressor
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,
D: Send,
impl<D> Sync for Decompressor<D> where
D: Sync,
D: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,