Struct ZlibEncoder
struct ZlibEncoder<W: Write> { ... }
A Zlib 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 ZlibEncoders:
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> ZlibEncoder<W>
fn new(options: Options, btype: BlockType, sink: W) -> Result<Self, Error>Creates a new Zlib 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 Zlib 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 Zlib 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) -> &WGets a reference to the underlying writer.
fn get_mut(self: &mut Self) -> &mut WGets 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 ZlibEncoder<W>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for ZlibEncoder<W>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for ZlibEncoder<W>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for ZlibEncoder<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for ZlibEncoder<W>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for ZlibEncoder<W>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for ZlibEncoder<W>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<W> Freeze for ZlibEncoder<W>
impl<W> RefUnwindSafe for ZlibEncoder<W>
impl<W> Send for ZlibEncoder<W>
impl<W> Sync for ZlibEncoder<W>
impl<W> Unpin for ZlibEncoder<W>
impl<W> UnsafeUnpin for ZlibEncoder<W>
impl<W> UnwindSafe for ZlibEncoder<W>
impl<W: Write> Drop for ZlibEncoder<W>
fn drop(self: &mut Self)
impl<W: Write> Write for ZlibEncoder<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 ZlibEncoder<W>
fn write(self: &mut Self, _buf: &[u8]) -> Result<usize>fn flush(self: &mut Self) -> Result<()>