git_filter_server/
processor.rs1use crate::parse_error;
2use anyhow::Result;
3use std::io::{Read, Write};
4
5#[derive(PartialEq, Clone, Copy, Hash)]
6pub enum ProcessingType {
7 Clean,
9 Smudge,
11}
12
13impl ProcessingType {
14 pub fn name(&self) -> &'static str {
15 match self {
16 ProcessingType::Clean => "clean",
17 ProcessingType::Smudge => "smudge",
18 }
19 }
20 pub fn done_name(&self) -> &'static str {
21 match self {
22 ProcessingType::Clean => "cleaned",
23 ProcessingType::Smudge => "smudged",
24 }
25 }
26 pub fn acc_name(&self) -> &'static str {
27 match self {
28 Self::Clean => "cleaning",
29 Self::Smudge => "smudging",
30 }
31 }
32}
33
34pub trait Processor {
37 fn process<R: Read, W: Write>(
39 &mut self,
40 _pathname: &str,
41 _process_type: ProcessingType,
42 _input: &mut R,
43 _output: &mut W,
44 ) -> Result<()> {
45 Err(parse_error!("processing is not supported").into())
46 }
47
48 fn schedule_process<R: Read>(
50 &mut self,
51 _pathname: &str,
52 _process_type: ProcessingType,
53 _input: &mut R,
54 ) -> Result<()> {
55 panic!("delayed processing is not implemented")
56 }
57
58 fn get_scheduled<W: Write>(
60 &mut self,
61 _pathname: &str,
62 _process_type: ProcessingType,
63 _output: &mut W,
64 ) -> Result<()> {
65 panic!("delayed processing is not implemented")
66 }
67 fn switch_to_wait(&mut self) {}
69
70 fn get_available(&mut self) -> Result<Vec<String>> {
72 panic!("delayed processing is not implemented")
73 }
74
75 fn should_delay(&self, _pathname: &str, _process_type: ProcessingType) -> bool {
78 false
79 }
80
81 fn supports_processing(&self, _process_type: ProcessingType) -> bool {
83 false
84 }
85}
86
87impl Processor for () {}