diff options
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r-- | src/config/mod.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 23a3e7d..cd79299 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,14 +1,15 @@ pub mod general; pub mod keymap; pub mod mimetype; +pub mod option; pub mod preview; pub mod theme; pub use self::general::AppConfig; pub use self::keymap::AppKeyMapping; -pub use self::mimetype::{AppMimetypeEntry, AppMimetypeRegistry}; -pub use self::preview::{JoshutoPreview, JoshutoPreviewEntry}; -pub use self::theme::{AppStyle, AppTheme}; +pub use self::mimetype::*; +pub use self::preview::*; +pub use self::theme::*; use serde::de::DeserializeOwned; use std::fs; @@ -16,15 +17,10 @@ use std::path::{Path, PathBuf}; use crate::CONFIG_HIERARCHY; -pub trait ConfigStructure { +pub trait TomlConfigFile { fn get_config(file_name: &str) -> Self; } -// implemented by config file implementations to turn a RawConfig into a Config -trait Flattenable<T> { - fn flatten(self) -> T; -} - // searches a list of folders for a given file in order of preference pub fn search_directories<P>(filename: &str, directories: &[P]) -> Option<PathBuf> where @@ -42,7 +38,8 @@ where // parses a config file into its appropriate format fn parse_to_config_file<T, S>(filename: &str) -> Option<S> where - T: DeserializeOwned + Flattenable<S>, + T: DeserializeOwned, + S: From<T>, { let file_path = search_directories(filename, &CONFIG_HIERARCHY)?; let file_contents = match fs::read_to_string(&file_path) { @@ -59,5 +56,5 @@ where return None; } }; - Some(config.flatten()) + Some(S::from(config)) } |