Debian Codegraph @

.cargo/vendor/flate2/examples/gzencoder-read.rs

raw
1 use flate2::read::GzEncoder;
2 use flate2::Compression;
3 use std::io;
4 use std::io::prelude::*;
5
6 // Print the GZ compressed representation of hello world
7 fn main() {
8 println!("{:?}", gzencoder_read_hello_world().unwrap());
9 }
10
11 // Return a vector containing the GZ compressed version of hello world
12 fn gzencoder_read_hello_world() -> io::Result<Vec<u8>> {
13 let mut result = Vec::new();
14 let c = b"hello world";
15 let mut z = GzEncoder::new(&c[..], Compression::fast());
16 z.read_to_end(&mut result)?;
17 Ok(result)
18 }