Struct flate2::GzBuilder
[−]
[src]
pub struct GzBuilder { /* fields omitted */ }
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 Builder 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(b"hello world")?; gz.finish()?;
Methods
impl Builder
[src]
fn new() -> Builder
[src]
Create a new blank builder with no header by default.
fn mtime(self, mtime: u32) -> Builder
[src]
Configure the mtime
field in the gzip header.
fn extra<T: Into<Vec<u8>>>(self, extra: T) -> Builder
[src]
Configure the extra
field in the gzip header.
fn filename<T: Into<Vec<u8>>>(self, filename: T) -> Builder
[src]
Configure the filename
field in the gzip header.
Panics
Panics if the filename
slice contains a zero.
fn comment<T: Into<Vec<u8>>>(self, comment: T) -> Builder
[src]
fn write<W: Write>(self, w: W, lvl: Compression) -> GzEncoder<W>
[src]
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
.
fn read<R: Read>(self, r: R, lvl: Compression) -> GzEncoder<R>
[src]
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.
fn buf_read<R>(self, r: R, lvl: Compression) -> GzEncoder<R> where
R: BufRead,
[src]
R: BufRead,
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.