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
use ::std::path::Path; use ::std::path::PathBuf; use crate::config::typ::EndecConfig; use crate::header::strategy::Verbosity; use crate::key::Key; #[derive(Debug)] pub struct DecryptConfig { files: Vec<PathBuf>, raw_key: Key, verbosity: Verbosity, overwrite: bool, delete_input: bool, output_dir: Option<PathBuf>, } impl DecryptConfig { #[allow(clippy::too_many_arguments)] pub fn new( files: Vec<PathBuf>, raw_key: Key, verbosity: Verbosity, overwrite: bool, delete_input: bool, output_dir: Option<PathBuf>, ) -> Self { assert!(!files.is_empty()); DecryptConfig { files, raw_key, verbosity, overwrite, delete_input, output_dir, } } pub fn output_dir(&self) -> Option<&Path> { match &self.output_dir { Some(dir) => Some(dir.as_path()), None => None, } } } impl EndecConfig for DecryptConfig { 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(pth) => Some(pth), None => None, } } }