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
sourceimpl<'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>ⓘNotable traits for AutoFlushDecoder<'_, W, F>impl<W: Write, F: FnMut(Result<()>)> Write for AutoFlushDecoder<'_, W, F>
pub fn auto_flush(self) -> AutoFlushDecoder<'a, W>ⓘNotable traits for AutoFlushDecoder<'_, W, F>impl<W: Write, F: FnMut(Result<()>)> Write for AutoFlushDecoder<'_, W, F>
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>ⓘNotable traits for AutoFlushDecoder<'_, W, F>impl<W: Write, F: FnMut(Result<()>)> Write for AutoFlushDecoder<'_, W, F>
pub fn on_flush<F: FnMut(Result<()>)>(self, f: F) -> AutoFlushDecoder<'a, W, F>ⓘNotable traits for AutoFlushDecoder<'_, W, F>impl<W: Write, F: FnMut(Result<()>)> Write for AutoFlushDecoder<'_, 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
sourceimpl<W: Write> Write for Decoder<'_, W>
impl<W: Write> Write for Decoder<'_, W>
sourcefn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
1.0.0 · sourcefn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations
impl<'a, W> RefUnwindSafe for Decoder<'a, W> where
W: RefUnwindSafe,
impl<'a, W> Send for Decoder<'a, W> where
W: Send,
impl<'a, W> !Sync for Decoder<'a, W>
impl<'a, W> Unpin for Decoder<'a, W> where
W: Unpin,
impl<'a, W> UnwindSafe for Decoder<'a, W> where
W: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more