Add default traits and open function to CompressionEngine
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use std::io::{Read,Write};
|
||||
use std::path::PathBuf;
|
||||
use log::*;
|
||||
|
||||
@@ -25,17 +25,11 @@ impl CompressionEngine for CompressionEngineGZip {
|
||||
true
|
||||
}
|
||||
|
||||
fn cat(&self, file_path: PathBuf) -> Result<()> {
|
||||
debug!("COMPRESSION: Outputting {:?} to STDOUT using {:?}", file_path, *self);
|
||||
fn open(&self, file_path: PathBuf) -> Result<Box<dyn Read>> {
|
||||
debug!("COMPRESSION: Opening {:?} using {:?}", file_path, *self);
|
||||
|
||||
let mut stdout = io::stdout().lock();
|
||||
let file = File::open(file_path)?;
|
||||
let mut gzip_read = GzDecoder::new(file);
|
||||
|
||||
io::copy(&mut gzip_read, &mut stdout)?;
|
||||
stdout.flush()?;
|
||||
|
||||
Ok(())
|
||||
Ok(Box::new(GzDecoder::new(file)))
|
||||
}
|
||||
|
||||
fn create(&self, file_path: PathBuf) -> Result<Box<dyn Write>> {
|
||||
|
||||
Reference in New Issue
Block a user