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§
§impl<R> Decoder<'static, R>where
R: BufRead,
impl<R> Decoder<'static, R>where
R: BufRead,
pub fn with_buffer(reader: R) -> Result<Decoder<'static, R>, Error>
pub fn with_buffer(reader: R) -> Result<Decoder<'static, R>, Error>
Creates a new decoder around a BufRead
.
pub fn with_dictionary(
reader: R,
dictionary: &[u8],
) -> Result<Decoder<'static, R>, Error>
pub fn with_dictionary( reader: R, dictionary: &[u8], ) -> Result<Decoder<'static, R>, Error>
Creates a new decoder, using an existing dictionary.
The dictionary must be the same as the one used during compression.
§impl<'a, R> Decoder<'a, R>where
R: BufRead,
impl<'a, R> Decoder<'a, R>where
R: BufRead,
pub fn with_context(reader: R, context: &'a mut DCtx<'static>) -> Decoder<'a, R> ⓘ
pub fn with_context(reader: R, context: &'a mut DCtx<'static>) -> Decoder<'a, R> ⓘ
Creates a new decoder which employs the provided context for deserialization.
pub fn single_frame(self) -> Decoder<'a, R> ⓘ
pub fn single_frame(self) -> Decoder<'a, R> ⓘ
Sets this Decoder
to stop after the first frame.
By default, it keeps concatenating frames until EOF is reached.
pub fn with_prepared_dictionary<'b>(
reader: R,
dictionary: &DecoderDictionary<'b>,
) -> Result<Decoder<'a, R>, Error>where
'b: 'a,
pub fn with_prepared_dictionary<'b>(
reader: R,
dictionary: &DecoderDictionary<'b>,
) -> Result<Decoder<'a, R>, Error>where
'b: 'a,
Creates a new decoder, using an existing DecoderDictionary
.
The dictionary must be the same as the one used during compression.
pub fn with_ref_prefix<'b>(
reader: R,
ref_prefix: &'b [u8],
) -> Result<Decoder<'a, R>, Error>where
'b: 'a,
pub fn with_ref_prefix<'b>(
reader: R,
ref_prefix: &'b [u8],
) -> Result<Decoder<'a, R>, Error>where
'b: 'a,
Creates a new decoder, using a ref prefix.
The prefix must be the same as the one used during compression.
pub fn recommended_output_size() -> usize
pub fn recommended_output_size() -> usize
Recommendation for the size of the output buffer.
pub 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.
pub 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.
pub fn set_parameter(&mut self, parameter: DParameter) -> Result<(), Error>
pub fn set_parameter(&mut self, parameter: DParameter) -> Result<(), Error>
Sets a decompression parameter on the decompression stream.
pub fn window_log_max(&mut self, log_distance: u32) -> Result<(), Error>
pub fn window_log_max(&mut self, log_distance: u32) -> Result<(), Error>
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§
§impl<R> Read for Decoder<'_, R>where
R: BufRead,
impl<R> Read for Decoder<'_, R>where
R: BufRead,
§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
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