pub struct GzBuilder { /* private fields */ }
Expand description

A builder structure to create a new gzip Encoder.

This structure controls header configuration options such as the filename.

Examples

use std::io::prelude::*;
use std::fs::File;
use flate2::GzBuilder;
use flate2::Compression;

// GzBuilder opens a file and writes a sample string using GzBuilder pattern

let f = File::create("examples/hello_world.gz")?;
let mut gz = GzBuilder::new()
                .filename("hello_world.txt")
                .comment("test file, please delete")
                .write(f, Compression::default());
gz.write_all(b"hello world")?;
gz.finish()?;

Implementations

Create a new blank builder with no header by default.

Configure the mtime field in the gzip header.

Configure the operating_system field in the gzip header.

Configure the extra field in the gzip header.

Configure the filename field in the gzip header.

Panics

Panics if the filename slice contains a zero.

Configure the comment field in the gzip header.

Panics

Panics if the comment slice contains a zero.

Consume this builder, creating a writer encoder in the process.

The data written to the returned encoder will be compressed and then written out to the supplied parameter w.

Consume this builder, creating a reader encoder in the process.

Data read from the returned encoder will be the compressed version of the data read from the given reader.

Consume this builder, creating a reader encoder in the process.

Data read from the returned encoder will be the compressed version of the data read from the given reader.

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.