Add config module

This commit is contained in:
Matthias Beyer 2016-04-22 17:27:44 +02:00
parent 0363a6a4d4
commit ef86c5e1ff
2 changed files with 20 additions and 0 deletions

View file

@ -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"))
}

View file

@ -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;