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 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()?;
Implementations§
source§impl Builder
impl Builder
sourcepub fn extra<T: Into<Vec<u8>>>(self, extra: T) -> Builder
pub fn extra<T: Into<Vec<u8>>>(self, extra: T) -> Builder
Configure the extra
field in the gzip header.
sourcepub fn filename<T: Into<Vec<u8>>>(self, filename: T) -> Builder
pub fn filename<T: Into<Vec<u8>>>(self, filename: T) -> Builder
Configure the filename
field in the gzip header.
Panics
Panics if the filename
slice contains a zero.
sourcepub fn write<W: Write>(self, w: W, lvl: Compression) -> GzEncoder<W> ⓘ
pub fn write<W: Write>(self, w: W, lvl: Compression) -> GzEncoder<W> ⓘ
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
.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more