[−][src]Struct flate2::GzBuilder
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()?;
Methods
impl GzBuilder
[src]
impl GzBuilder
pub fn new() -> GzBuilder
[src]
pub fn new() -> GzBuilder
Create a new blank builder with no header by default.
pub fn mtime(self, mtime: u32) -> GzBuilder
[src]
pub fn mtime(self, mtime: u32) -> GzBuilder
Configure the mtime
field in the gzip header.
pub fn operating_system(self, os: u8) -> GzBuilder
[src]
pub fn operating_system(self, os: u8) -> GzBuilder
Configure the operating_system
field in the gzip header.
pub fn extra<T: Into<Vec<u8>>>(self, extra: T) -> GzBuilder
[src]
pub fn extra<T: Into<Vec<u8>>>(self, extra: T) -> GzBuilder
Configure the extra
field in the gzip header.
pub fn filename<T: Into<Vec<u8>>>(self, filename: T) -> GzBuilder
[src]
pub fn filename<T: Into<Vec<u8>>>(self, filename: T) -> GzBuilder
Configure the filename
field in the gzip header.
Panics
Panics if the filename
slice contains a zero.
pub fn comment<T: Into<Vec<u8>>>(self, comment: T) -> GzBuilder
[src]
pub fn comment<T: Into<Vec<u8>>>(self, comment: T) -> GzBuilder
ⓘImportant traits for GzEncoder<W>pub fn write<W: Write>(self, w: W, lvl: Compression) -> GzEncoder<W>
[src]
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
.
ⓘImportant traits for GzEncoder<R>pub fn read<R: Read>(self, r: R, lvl: Compression) -> GzEncoder<R>
[src]
pub fn read<R: Read>(self, r: R, lvl: Compression) -> GzEncoder<R>
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.
ⓘImportant traits for GzEncoder<R>pub fn buf_read<R>(self, r: R, lvl: Compression) -> GzEncoder<R> where
R: BufRead,
[src]
pub fn buf_read<R>(self, r: R, lvl: Compression) -> GzEncoder<R> where
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.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
ⓘImportant traits for &'a mut Rfn borrow(&self) -> &T
[src]
fn borrow(&self) -> &T
Immutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
ⓘImportant traits for &'a mut Rfn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more