use std::collections::VecDeque;
use std::io;
use zstd::Encoder;

fn main() {
    let inputs = "hello world".repeat(100);
    let outputs = compress_manually(1, inputs.as_bytes().to_vec().into());

    println!("Inputs len: {}", inputs.len());
    println!("Outputs len: {}", outputs.len());
    println!("{:x?}", outputs);
}

// 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();
// }

// This function does the same thing, directly using an `Encoder`:
fn compress_manually(level: i32, mut input: VecDeque<u8>) -> Vec<u8> {
    let mut output: Vec<u8> = vec![];
    let mut encoder = Encoder::new(&mut output, level).unwrap();
    io::copy(&mut input, &mut encoder).unwrap();
    encoder.finish().unwrap();
    output
}

