Function final_compression::decompressed_reader
source · pub fn decompressed_reader(
src: Box<dyn Read>,
compression_type: CompressionType
) -> Result<Box<dyn Read>, Box<dyn Error>>
Expand description
Create a decompress reader to wrap another reader.
The being wrapped reader should be a compressed datastream, and the wrapped reader is the decompressed stream.
All data read by the raw reader will be decompressed by the decompressor before application consumes it.
Example:
use final_compression::{decompressed_reader, CompressionType};
let input = std::fs::File::open("test.out.txt.doc.gz").unwrap();
let mut gz_in = crate::final_compression::decompressed_reader(Box::new(input), CompressionType::Gzip).unwrap();
let mut data = String::new();
gz_in.read_to_string(&mut data);
drop(gz_in);
// Data should be "hello world" (we have written that file in the other test)