use crate::parse_error;
use anyhow::Result;
use std::io::{Read, Write};
#[derive(PartialEq, Clone, Copy, Hash)]
pub enum ProcessingType {
Clean,
Smudge,
}
impl ProcessingType {
pub fn name(&self) -> &'static str {
match self {
ProcessingType::Clean => "clean",
ProcessingType::Smudge => "smudge",
}
}
pub fn done_name(&self) -> &'static str {
match self {
ProcessingType::Clean => "cleaned",
ProcessingType::Smudge => "smudged",
}
}
pub fn acc_name(&self) -> &'static str {
match self {
Self::Clean => "cleaning",
Self::Smudge => "smudging",
}
}
}
pub trait Processor {
fn process<R: Read, W: Write>(
&mut self,
_pathname: &str,
_process_type: ProcessingType,
_input: &mut R,
_output: &mut W,
) -> Result<()> {
Err(parse_error!("processing is not supported").into())
}
fn schedule_process<R: Read>(
&mut self,
_pathname: &str,
_process_type: ProcessingType,
_input: &mut R,
) -> Result<()> {
panic!("delayed processing is not implemented")
}
fn get_scheduled<W: Write>(
&mut self,
_pathname: &str,
_process_type: ProcessingType,
_output: &mut W,
) -> Result<()> {
panic!("delayed processing is not implemented")
}
fn switch_to_wait(&mut self) {}
fn get_available(&mut self) -> Result<Vec<String>> {
panic!("delayed processing is not implemented")
}
fn should_delay(&self, _pathname: &str, _process_type: ProcessingType) -> bool {
false
}
fn supports_processing(&self, _process_type: ProcessingType) -> bool {
false
}
}
impl Processor for () {}