1 extern crate flate2; 2 3 use flate2::write::GzEncoder; 4 use flate2::Compression; 5 use std::io::prelude::*; 6 7 // Vec<u8> implements Write to print the compressed bytes of sample string main()8fn main() { 9 let mut e = GzEncoder::new(Vec::new(), Compression::default()); 10 e.write_all(b"Hello World").unwrap(); 11 println!("{:?}", e.finish().unwrap()); 12 } 13