// // melib // // Copyright 2024 Emmanouil Pitsidianakis // // This file is part of melib. // // melib is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // melib is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with melib. If not, see . // // SPDX-License-Identifier: EUPL-1.2 OR GPL-3.0-or-later use crate::{email::Address, SpecialUsageMailbox}; use indexmap::IndexMap; use regex::bytes::Regex; use std::path::PathBuf; #[derive(Serialize, Deserialize)] pub struct FccDirEntry { pattern: Box, folder: Option>, //tags: Vec, } impl FccDirEntry { pub fn matches<'fcc>(&'fcc self, from: &Address) -> Option<&'fcc str> { let reg = Regex::new(&self.pattern).ok()?; if reg.is_match(from.raw()) { return self.folder.as_ref().map(|s| s.as_ref()); } None } } #[derive(Serialize, Deserialize)] pub enum FccDirs { None, Folder(Box), SpecialFolder(SpecialUsageMailbox), Map(Vec), } impl Default for FccDirs { fn default() -> Self { Self::SpecialFolder(SpecialUsageMailbox::Sent) } } #[derive(Default, Serialize, Deserialize)] pub struct Configuration { pub library_file_path: Option, pub fcc_dirs: FccDirs, }