Struct zstd::Encoder [] [src]

pub struct Encoder<W: Write> {
    // some fields omitted
}

An encoder that compress and forward data to another writer.

This allows to compress a stream of data (good for files or heavy network stream).

Don't forget to call finish() before dropping it!

Note: The zstd library has its own internal input buffer (~128kb).

Methods

impl<W: Write> Encoder<W>
[src]

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

Creates a new encoder.

level: compression level (1-21)

fn with_dictionary(writer: W, level: i32, dictionary: &[u8]) -> Result<Self>

Creates a new encoder, using an existing dictionary.

(Provides better compression ratio for small files, but requires the dictionary to be present during decompression.)

fn finish(self) -> Result<W>

Finishes the stream. You need to call this after writing your stuff.

This returns the inner writer in case you need it.

fn recommended_input_size() -> usize

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

Trait Implementations

impl<W: Write> Write for Encoder<W>
[src]

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

Write a buffer into this object, returning how many bytes were written. Read more

fn flush(&mut self) -> Result<()>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

fn write_all(&mut self, buf: &[u8]) -> Result<()Error>
1.0.0

Attempts to write an entire buffer into this write. Read more

fn write_fmt(&mut self, fmt: Arguments) -> Result<()Error>
1.0.0

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self
1.0.0

Creates a "by reference" adaptor for this instance of Write. Read more