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
use ::std::fmt::Debug; use ::std::path::Path; use ::std::path::PathBuf; use crate::header::strategy::Verbosity; use crate::key::Key; #[derive(Debug, Clone, Copy)] pub enum Extension<'a> { Add(&'a str), Strip, } pub trait EndecConfig: Debug { fn files(&self) -> &[PathBuf]; fn raw_key(&self) -> &Key; fn verbosity(&self) -> Verbosity; fn debug(&self) -> bool { self.verbosity().debug() } fn quiet(&self) -> bool { self.verbosity().quiet() } fn overwrite(&self) -> bool; fn delete_input(&self) -> bool; fn output_dir(&self) -> Option<&Path>; } #[cfg(test)] #[derive(Debug)] pub struct MockEndecConfig { pub files: Vec<PathBuf>, pub raw_key: Key, pub verbosity: Verbosity, pub overwrite: bool, pub delete_input: bool, pub output_dir: Option<PathBuf>, } #[cfg(test)] impl EndecConfig for MockEndecConfig { fn files(&self) -> &[PathBuf] { &self.files } fn raw_key(&self) -> &Key { &self.raw_key } fn verbosity(&self) -> Verbosity { self.verbosity } fn overwrite(&self) -> bool { self.overwrite } fn delete_input(&self) -> bool { self.delete_input } fn output_dir(&self) -> Option<&Path> { match &self.output_dir { Some(dir) => Some(dir.as_path()), None => None, } } }