Debian Codegraph @

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

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