diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-04-22 17:27:44 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-06-04 15:34:02 +0200 |
commit | ef86c5e1ffbd8fb01c4c638d0da18256c2920391 (patch) | |
tree | 6ff884a34357aee636d63ca95d81e7c1938ebcfe /libimagdiary | |
parent | 0363a6a4d41ece736da473e60c33e458b83e197d (diff) |
Add config module
Diffstat (limited to 'libimagdiary')
-rw-r--r-- | libimagdiary/src/config.rs | 19 | ||||
-rw-r--r-- | libimagdiary/src/lib.rs | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libimagdiary/src/config.rs b/libimagdiary/src/config.rs new file mode 100644 index 00000000..93749289 --- /dev/null +++ b/libimagdiary/src/config.rs @@ -0,0 +1,19 @@ +use toml::Value; + +use libimagrt::runtime::Runtime; + +pub fn get_default_diary_name(rt: &Runtime) -> Option<String> { + get_diary_config_section(rt) + .and_then(|config| { + match config.lookup("default_diary") { + Some(&Value::String(ref s)) => Some(s.clone()), + _ => None, + } + }) +} + +pub fn get_diary_config_section<'a>(rt: &'a Runtime) -> Option<&'a Value> { + rt.config() + .map(|config| config.config()) + .and_then(|config| config.lookup("diary")) +} diff --git a/libimagdiary/src/lib.rs b/libimagdiary/src/lib.rs index 5f4567e7..0e6256e6 100644 --- a/libimagdiary/src/lib.rs +++ b/libimagdiary/src/lib.rs @@ -13,6 +13,7 @@ extern crate libimagrt; module_entry_path_mod!("diary", "0.1.0"); +pub mod config; pub mod error; pub mod diaryid; pub mod diary; |