use std::io;
use std::path::{Path, PathBuf};
#[allow(unused_variables)]
pub trait Compressor {
fn name(&self) -> &str;
fn extension(&self) -> &str {
self.name()
}
fn default_compressed_filename(&self, in_path: &Path) -> String {
format!(
"{}.{}",
in_path.file_name().unwrap().to_str().unwrap(),
self.extension()
)
}
fn default_extracted_filename(&self, in_path: &Path) -> String {
if in_path.extension().is_none() {
return ".".to_string();
}
in_path.file_stem().unwrap().to_str().unwrap().to_string()
}
fn compress(&self, input: CmprssInput, output: CmprssOutput) -> Result<(), io::Error> {
cmprss_error("compress_target unimplemented")
}
fn extract(&self, input: CmprssInput, output: CmprssOutput) -> Result<(), io::Error> {
cmprss_error("extract_target unimplemented")
}
}
pub fn cmprss_error(message: &str) -> Result<(), io::Error> {
Err(io::Error::new(io::ErrorKind::Other, message))
}
#[derive(Debug)]
pub enum CmprssInput {
Path(Vec<PathBuf>),
Pipe(std::io::Stdin),
}
#[derive(Debug)]
pub enum CmprssOutput {
Path(PathBuf),
Pipe(std::io::Stdout),
}