pub struct Decoder<'a, R> { /* private fields */ }
Expand description
A decoder that decompress input data from another Read
.
This allows to read a stream of compressed data (good for files or heavy network stream).
Implementations§
source§impl<R: BufRead> Decoder<'static, R>
impl<R: BufRead> Decoder<'static, R>
sourcepub fn with_buffer(reader: R) -> Result<Self>
pub fn with_buffer(reader: R) -> Result<Self>
Creates a new decoder around a BufRead
.
sourcepub fn with_dictionary(reader: R, dictionary: &[u8]) -> Result<Self>
pub fn with_dictionary(reader: R, dictionary: &[u8]) -> Result<Self>
Creates a new decoder, using an existing dictionary.
The dictionary must be the same as the one used during compression.
source§impl<'a, R: BufRead> Decoder<'a, R>
impl<'a, R: BufRead> Decoder<'a, R>
sourcepub fn with_context(reader: R, context: &'a mut DCtx<'static>) -> Self
pub fn with_context(reader: R, context: &'a mut DCtx<'static>) -> Self
Creates a new decoder which employs the provided context for deserialization.
sourcepub fn single_frame(self) -> Self
pub fn single_frame(self) -> Self
Sets this Decoder
to stop after the first frame.
By default, it keeps concatenating frames until EOF is reached.
sourcepub fn with_prepared_dictionary<'b>(
reader: R,
dictionary: &DecoderDictionary<'b>,
) -> Result<Self>where
'b: 'a,
pub fn with_prepared_dictionary<'b>(
reader: R,
dictionary: &DecoderDictionary<'b>,
) -> Result<Self>where
'b: 'a,
Creates a new decoder, using an existing DecoderDictionary
.
The dictionary must be the same as the one used during compression.
sourcepub fn with_ref_prefix<'b>(reader: R, ref_prefix: &'b [u8]) -> Result<Self>where
'b: 'a,
pub fn with_ref_prefix<'b>(reader: R, ref_prefix: &'b [u8]) -> Result<Self>where
'b: 'a,
Creates a new decoder, using a ref prefix.
The prefix must be the same as the one used during compression.
sourcepub fn recommended_output_size() -> usize
pub fn recommended_output_size() -> usize
Recommendation for the size of the output buffer.
sourcepub fn get_mut(&mut self) -> &mut R
pub fn get_mut(&mut self) -> &mut R
Acquire a mutable reference to the underlying reader.
Note that mutation of the reader may result in surprising results if this decoder is continued to be used.
sourcepub fn finish(self) -> R
pub fn finish(self) -> R
Return the inner Read
.
Calling finish()
is not required after reading a stream -
just use it if you need to get the Read
back.
sourcepub fn set_parameter(&mut self, parameter: DParameter) -> Result<()>
pub fn set_parameter(&mut self, parameter: DParameter) -> Result<()>
Sets a decompression parameter on the decompression stream.
sourcepub fn window_log_max(&mut self, log_distance: u32) -> Result<()>
pub fn window_log_max(&mut self, log_distance: u32) -> Result<()>
Sets the maximum back-reference distance.
The actual maximum distance is going to be 2^log_distance
.
This will need to at least match the value set when compressing.
Trait Implementations§
source§impl<R: BufRead> Read for Decoder<'_, R>
impl<R: BufRead> Read for Decoder<'_, R>
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read more