File: zlibencoder-write.rs

package info (click to toggle)
rust-flate2 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 800 kB
  • sloc: makefile: 2
file content (10 lines) | stat: -rw-r--r-- 327 bytes parent folder | download | duplicates (41)
1
2
3
4
5
6
7
8
9
10
use flate2::write::ZlibEncoder;
use flate2::Compression;
use std::io::prelude::*;

// Vec<u8> implements Write to print the compressed bytes of sample string
fn main() {
    let mut e = ZlibEncoder::new(Vec::new(), Compression::default());
    e.write_all(b"Hello World").unwrap();
    println!("{:?}", e.finish().unwrap());
}