1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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 () {}