pub struct Decoder<'a, W: Write> { /* private fields */ }Expand description
A decoder that decompress and forward data to another writer.
Note that you probably want to flush() after writing your stream content.
You can use auto_flush() to automatically flush the writer on drop.
Implementations§
Source§impl<W: Write> Decoder<'static, W>
impl<W: Write> Decoder<'static, W>
Sourcepub fn with_dictionary(writer: W, dictionary: &[u8]) -> Result<Self>
pub fn with_dictionary(writer: W, dictionary: &[u8]) -> Result<Self>
Creates a new decoder, using an existing dictionary.
(Provides better compression ratio for small files, but requires the dictionary to be present during decompression.)
Source§impl<'a, W: Write> Decoder<'a, W>
impl<'a, W: Write> Decoder<'a, W>
Sourcepub fn with_writer(writer: Writer<W, Decoder<'a>>) -> Self
pub fn with_writer(writer: Writer<W, Decoder<'a>>) -> Self
Creates a new decoder around the given prepared zio writer.
§Examples
fn wrap<W: std::io::Write>(writer: W) -> zstd::stream::write::Decoder<'static, W> {
let decoder = zstd::stream::raw::Decoder::new().unwrap();
let writer = zstd::stream::zio::Writer::new(writer, decoder);
zstd::stream::write::Decoder::with_writer(writer)
}Sourcepub fn with_decoder(writer: W, decoder: Decoder<'a>) -> Self
pub fn with_decoder(writer: W, decoder: Decoder<'a>) -> Self
Creates a new decoder around the given Write and raw decoder.
Sourcepub fn with_prepared_dictionary<'b>(
writer: W,
dictionary: &DecoderDictionary<'b>,
) -> Result<Self>where
'b: 'a,
pub fn with_prepared_dictionary<'b>(
writer: W,
dictionary: &DecoderDictionary<'b>,
) -> Result<Self>where
'b: 'a,
Creates a new decoder, using an existing prepared DecoderDictionary.
(Provides better compression ratio for small files, but requires the dictionary to be present during decompression.)
Sourcepub fn get_mut(&mut self) -> &mut W
pub fn get_mut(&mut self) -> &mut W
Acquires a mutable reference to the underlying writer.
Note that mutation of the writer may result in surprising results if this decoder is continued to be used.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Returns the inner Write.
Sourcepub fn recommended_input_size() -> usize
pub fn recommended_input_size() -> usize
Return a recommendation for the size of data to write at once.
Sourcepub fn auto_flush(self) -> AutoFlushDecoder<'a, W> ⓘ
pub fn auto_flush(self) -> AutoFlushDecoder<'a, W> ⓘ
Returns a wrapper around self that will flush the stream on drop.
Sourcepub fn on_flush<F: FnMut(Result<()>)>(self, f: F) -> AutoFlushDecoder<'a, W, F> ⓘ
pub fn on_flush<F: FnMut(Result<()>)>(self, f: F) -> AutoFlushDecoder<'a, W, F> ⓘ
Returns a decoder that will flush the stream on drop.
Calls the given callback with the result from flush(). This runs during drop so it’s
important that the provided callback doesn’t panic.
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<W: Write> Write for Decoder<'_, W>
impl<W: Write> Write for Decoder<'_, W>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)