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_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.
Panic
Panics on drop if an error happens when flushing the stream.
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()
.
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
)