Sha256: 9aafc6f899a83930cd16a2ae9d6ace0f8e16e67e828be788748789aedad7c850

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 KB

Contents

use std::env;
use std::io::{self, Write};
use std::str::FromStr;

fn main() {
    match env::args().nth(1) {
        None => {
            writeln!(
                &mut io::stderr(),
                "Invalid option. Usage: `stream [-d|-1..-22]`"
            )
            .unwrap();
        }
        Some(ref option) if option == "-d" => decompress(),
        Some(ref option) => {
            if option.starts_with('-') {
                let level = match i32::from_str(&option[1..]) {
                    Ok(level) => level,
                    Err(e) => panic!("Error parsing compression level: {}", e),
                };
                compress(level);
            } else {
                writeln!(
                    &mut io::stderr(),
                    "Invalid option. Usage: `stream [-d|-1..-22]`"
                )
                .unwrap();
            }
        }
    }
}

fn compress(level: i32) {
    zstd::stream::copy_encode(io::stdin(), io::stdout(), level).unwrap();
}

fn decompress() {
    zstd::stream::copy_decode(io::stdin(), io::stdout()).unwrap();
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/zstd-0.13.2/examples/stream.rs
wasmtime-28.0.0 ./ext/cargo-vendor/zstd-0.13.2/examples/stream.rs
wasmtime-27.0.0 ./ext/cargo-vendor/zstd-0.13.2/examples/stream.rs
wasmtime-26.0.0 ./ext/cargo-vendor/zstd-0.13.2/examples/stream.rs
wasmtime-25.0.2 ./ext/cargo-vendor/zstd-0.13.2/examples/stream.rs
wasmtime-25.0.1 ./ext/cargo-vendor/zstd-0.13.2/examples/stream.rs
wasmtime-25.0.0 ./ext/cargo-vendor/zstd-0.13.2/examples/stream.rs
wasmtime-24.0.0 ./ext/cargo-vendor/zstd-0.13.2/examples/stream.rs
wasmtime-23.0.2 ./ext/cargo-vendor/zstd-0.13.1/examples/stream.rs
wasmtime-22.0.0 ./ext/cargo-vendor/zstd-0.13.1/examples/stream.rs
wasmtime-21.0.1 ./ext/cargo-vendor/zstd-0.13.1/examples/stream.rs
wasmtime-20.0.2 ./ext/cargo-vendor/zstd-0.13.1/examples/stream.rs
wasmtime-20.0.0 ./ext/cargo-vendor/zstd-0.13.1/examples/stream.rs