]>
git.proxmox.com Git - cargo.git/blob - vendor/flate2-0.2.20/examples/gzencoder-read.rs
3 use std
::io
::prelude
::*;
5 use flate2
::Compression
;
6 use flate2
::read
::GzEncoder
;
8 // Print the GZ compressed representation of hello world
10 println
!("{:?}", gzencoder_read_hello_world().unwrap());
13 // Return a vector containing the GZ compressed version of hello world
14 fn gzencoder_read_hello_world() -> io
::Result
<Vec
<u8>> {
15 let mut ret_vec
= [0;100];
16 let c
= b
"hello world";
17 let mut z
= GzEncoder
::new(&c
[..], Compression
::Fast
);
18 let count
= z
.read(&mut ret_vec
)?
;
19 Ok(ret_vec
[0..count
].to_vec())