pub fn compressed_writer<T: Into<ParamSet>>(
    out: Box<dyn Write>,
    compression_type: CompressionType,
    option: T
) -> Result<Box<dyn Write>, Box<dyn Error>>
Expand description

Create a compressing writer to wrap another writer.

The being wrapped writer should be a raw writer, and the wrapped writer is the compressing writer.

All data written to the wrapped writer are compressed and then written to the actual writer.

Example:

use final_compression::{compressed_writer, CompressionType};
let out = std::fs::File::create("test.out.txt.doc.gz").unwrap();
let mut gz_out = crate::final_compression::compressed_writer(Box::new(out), CompressionType::Gzip, "level=3").unwrap();
gz_out.write("hello world".as_bytes()).unwrap();
drop(gz_out);
// Now out.txt.gz should be the compressed version of `hello world`.
// You can use `gunzip out.txt.gz` to verify the content.