Struct Decoder

struct Decoder<'a, W: Write> { ... }

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

impl<'a, W: Write> Decoder<'a, W>

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)
}
fn with_decoder(writer: W, decoder: Decoder<'a>) -> Self

Creates a new decoder around the given Write and raw decoder.

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.)

fn get_ref(self: &Self) -> &W

Acquires a reference to the underlying writer.

fn get_mut(self: &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.

fn into_inner(self: Self) -> W

Returns the inner Write.

fn recommended_input_size() -> usize

Return a recommendation for the size of data to write at once.

fn auto_flush(self: Self) -> AutoFlushDecoder<'a, W>

Returns a wrapper around self that will flush the stream on drop.

fn on_flush<F: FnMut(io::Result<()>)>(self: 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.

fn set_parameter(self: &mut Self, parameter: DParameter) -> Result<()>

Sets a decompression parameter on the decompression stream.

fn window_log_max(self: &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.

impl<W: Write> Decoder<'static, W>

fn new(writer: W) -> Result<Self>

Creates a new decoder.

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.)

impl<'a, W> Freeze for Decoder<'a, W>

impl<'a, W> RefUnwindSafe for Decoder<'a, W>

impl<'a, W> Send for Decoder<'a, W>

impl<'a, W> Sync for Decoder<'a, W>

impl<'a, W> Unpin for Decoder<'a, W>

impl<'a, W> UnsafeUnpin for Decoder<'a, W>

impl<'a, W> UnwindSafe for Decoder<'a, W>

impl<T> Any for Decoder<'a, W>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Decoder<'a, W>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Decoder<'a, W>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for Decoder<'a, W>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Decoder<'a, W>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Decoder<'a, W>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Decoder<'a, W>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<W: Write> Write for Decoder<'_, W>

fn write(self: &mut Self, buf: &[u8]) -> Result<usize>
fn flush(self: &mut Self) -> Result<()>