pub struct Decoder<'a, R> {
reader: Reader<R, Decoder<'a>>,
}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).
Fields§
§reader: Reader<R, Decoder<'a>>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: &'a DecoderDictionary<'b>,
) -> Result<Self>where
'b: 'a,
pub fn with_prepared_dictionary<'b>(
reader: R,
dictionary: &'a 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_frame(&mut self) -> Result<()>
pub fn finish_frame(&mut self) -> Result<()>
Consume the rest of the current frame, so the underlying reader is left pointing just after it.
zstd can hand out the last of the decoded data before it has read the frame epilogue, so a reader that stops as soon as it has the bytes it wanted leaves the input somewhere inside the frame. Call this to line the reader back up with the end of the frame - for instance to carry on reading whatever follows the compressed section.
This does not touch the underlying reader if the frame is already complete, and never starts decoding the next frame.
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.
This consumes the rest of the current frame first, so the reader is
returned pointing just after it - see Self::finish_frame(). That
may read from the underlying reader, and any error doing so is
ignored; call finish_frame() directly if you need to see it.
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