Struct GzEncoder

struct GzEncoder<R> { ... }

A gzip streaming encoder

This structure implements a Read interface. When read from, it reads uncompressed data from the underlying Read and provides the compressed data.

Examples

use std::io::prelude::*;
use std::io;
use flate2::Compression;
use flate2::read::GzEncoder;

// Return a vector containing the GZ compressed version of hello world

fn gzencode_hello_world() -> io::Result<Vec<u8>> {
    let mut ret_vec = Vec::new();
    let bytestring = b"hello world";
    let mut gz = GzEncoder::new(&bytestring[..], Compression::fast());
    gz.read_to_end(&mut ret_vec)?;
    Ok(ret_vec)
}

Implementations

impl<R> GzEncoder<R>

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

Acquires a reference to the underlying reader.

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

Acquires a mutable reference to the underlying reader.

Note that mutation of the reader may result in surprising results if this encoder is continued to be used.

fn into_inner(self: Self) -> R

Returns the underlying stream, consuming this encoder

impl<R: Read> GzEncoder<R>

fn new(r: R, level: Compression) -> GzEncoder<R>

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 GzBuilder type.

The data read from the stream r will be compressed and available through the returned reader.

impl<R> Freeze for GzEncoder<R>

impl<R> RefUnwindSafe for GzEncoder<R>

impl<R> Send for GzEncoder<R>

impl<R> Sync for GzEncoder<R>

impl<R> Unpin for GzEncoder<R>

impl<R> UnsafeUnpin for GzEncoder<R>

impl<R> UnwindSafe for GzEncoder<R>

impl<R: $crate::fmt::Debug> Debug for GzEncoder<R>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<R: Read + Write> Write for GzEncoder<R>

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

impl<R: Read> Read for GzEncoder<R>

fn read(self: &mut Self, into: &mut [u8]) -> Result<usize>

impl<T> Any for GzEncoder<R>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for GzEncoder<R>

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

impl<T> BorrowMut for GzEncoder<R>

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

impl<T> From for GzEncoder<R>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for GzEncoder<R>

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 GzEncoder<R>

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

impl<T, U> TryInto for GzEncoder<R>

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