use anyhow::Result; use log::*; use std::fs::File; use std::io::{Read, Write}; use std::path::PathBuf; use crate::compression_engine::CompressionEngine; #[derive(Debug, Eq, PartialEq, Clone, Default)] pub struct CompressionEngineNone {} impl CompressionEngineNone { pub fn new() -> CompressionEngineNone { CompressionEngineNone {} } } impl CompressionEngine for CompressionEngineNone { fn size(&self, file_path: PathBuf) -> Result { let item_file_metadata = file_path.metadata()?; Ok(item_file_metadata.len() as usize) } fn open(&self, file_path: PathBuf) -> Result> { debug!("COMPRESSION: Opening {:?} using {:?}", file_path, *self); Ok(Box::new(File::open(file_path)?)) } fn create(&self, file_path: PathBuf) -> Result> { debug!("COMPRESSION: Writting to {:?} using {:?}", file_path, *self); Ok(Box::new(File::create(file_path)?)) } }