Struct GzipEncoder

struct GzipEncoder<W: Write> { ... }

A Gzip encoder powered by the Zopfli algorithm, that compresses data using a DeflateEncoder. Most users will find using compress easier and more performant.

The caveats about short writes in DeflateEncoders carry over to GzipEncoders: for best performance and compression, it is best to avoid them. One way to ensure this is to use the new_buffered method.

Implementations

impl<W: Write> GzipEncoder<W>

fn new(options: Options, btype: BlockType, sink: W) -> Result<Self, Error>

Creates a new Gzip encoder that will operate according to the specified options.

fn new_buffered(options: Options, btype: BlockType, sink: W) -> Result<BufWriter<Self>, Error>

Creates a new Gzip encoder that operates according to the specified options and is wrapped with a buffer to guarantee that data is compressed in large chunks, which is necessary for decent performance and good compression ratio.

fn finish(self: Self) -> Result<W, Error>

Encodes any pending chunks of data and writes them to the sink, consuming the encoder and returning the wrapped sink. The sink will have received a complete Gzip stream when this method returns.

The encoder is automatically finished when dropped, but explicitly finishing it with this method allows handling I/O errors.

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

Gets a reference to the underlying writer.

fn get_mut(self: &mut Self) -> &mut W

Gets a mutable reference to the underlying writer.

Note that mutating the output/input state of the stream may corrupt this object, so care must be taken when using this method.

impl<T> Any for GzipEncoder<W>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for GzipEncoder<W>

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

impl<T> BorrowMut for GzipEncoder<W>

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

impl<T> From for GzipEncoder<W>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for GzipEncoder<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 GzipEncoder<W>

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

impl<T, U> TryInto for GzipEncoder<W>

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

impl<W> Freeze for GzipEncoder<W>

impl<W> RefUnwindSafe for GzipEncoder<W>

impl<W> Send for GzipEncoder<W>

impl<W> Sync for GzipEncoder<W>

impl<W> Unpin for GzipEncoder<W>

impl<W> UnsafeUnpin for GzipEncoder<W>

impl<W> UnwindSafe for GzipEncoder<W>

impl<W: Write> Drop for GzipEncoder<W>

fn drop(self: &mut Self)

impl<W: Write> Write for GzipEncoder<W>

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

impl<W: crate::io::Write> Write for GzipEncoder<W>

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