aboutsummaryrefslogtreecommitdiff
path: root/vendor/weezl/examples/lzw-compress.rs
blob: d71ab2de8695deb8e85d286753239ccf5eba807b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Compresses the input from stdin and writes the result to stdout.

use std::io::{self, BufWriter};

fn main() {
    match {
        let mut encoder = weezl::encode::Encoder::new(weezl::BitOrder::Msb, 8);
        let stdin = io::stdin();
        let stdin = stdin.lock();
        let stdout = io::stdout();
        let stdout = BufWriter::new(stdout.lock());
        encoder.into_stream(stdout).encode_all(stdin).status
    } {
        Ok(()) => (),
        Err(err) => eprintln!("{}", err),
    }
}