Struct GzEncoder
struct GzEncoder<W: Write> { ... }
A gzip streaming encoder
This structure exposes a Write interface that will emit compressed data
to the underlying writer W.
Examples
use *;
use Compression;
use GzEncoder;
// Vec<u8> implements Write to print the compressed bytes of sample string
#
Implementations
impl<W: Write> GzEncoder<W>
fn new(w: W, level: Compression) -> GzEncoder<W>Creates a new encoder which will use the given compression level.
The encoder is not configured specially for the emitted header. For header configuration, see the
GzBuildertype.The data written to the returned encoder will be compressed and then written to the stream
w.fn get_ref(self: &Self) -> &WAcquires a reference to the underlying writer.
fn get_mut(self: &mut Self) -> &mut WAcquires a mutable reference to the underlying writer.
Note that mutation of the writer may result in surprising results if this encoder is continued to be used.
fn try_finish(self: &mut Self) -> Result<()>Attempt to finish this output stream, writing out final chunks of data.
Note that this function can only be used once data has finished being written to the output stream. After this function is called then further calls to
writemay result in a panic.Panics
Attempts to write data to this stream may result in a panic after this function is called.
Errors
This function will perform I/O to complete this stream, and any I/O errors which occur will be returned from this function.
fn finish(self: Self) -> Result<W>Finish encoding this stream, returning the underlying writer once the encoding is done.
Note that this function may not be suitable to call in a situation where the underlying stream is an asynchronous I/O stream. To finish a stream the
try_finish(orshutdown) method should be used instead. To re-acquire ownership of a stream it is safe to call this method aftertry_finishorshutdownhas returnedOk.Errors
This function will perform I/O to complete this stream, and any I/O errors which occur will be returned from this function.
impl<R: Read + Write> Read for GzEncoder<R>
fn read(self: &mut Self, buf: &mut [u8]) -> Result<usize>
impl<T> Any for GzEncoder<W>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for GzEncoder<W>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for GzEncoder<W>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for GzEncoder<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for GzEncoder<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 GzEncoder<W>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for GzEncoder<W>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<W> Freeze for GzEncoder<W>
impl<W> RefUnwindSafe for GzEncoder<W>
impl<W> Send for GzEncoder<W>
impl<W> Sync for GzEncoder<W>
impl<W> Unpin for GzEncoder<W>
impl<W> UnsafeUnpin for GzEncoder<W>
impl<W> UnwindSafe for GzEncoder<W>
impl<W: $crate::fmt::Debug + Write> Debug for GzEncoder<W>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<W: Write> Drop for GzEncoder<W>
fn drop(self: &mut Self)
impl<W: Write> Write for GzEncoder<W>
fn write(self: &mut Self, buf: &[u8]) -> Result<usize>fn flush(self: &mut Self) -> Result<()>