From 50c4c16aaf99e835afdebf09ac1d8a425cbc8fcb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 30 May 2017 21:05:13 +0200 Subject: [PATCH] Fix libimagdiary for new toml interface --- libimagdiary/Cargo.toml | 1 + libimagdiary/src/config.rs | 8 +++++--- libimagdiary/src/lib.rs | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libimagdiary/Cargo.toml b/libimagdiary/Cargo.toml index dc1e7331..9139040f 100644 --- a/libimagdiary/Cargo.toml +++ b/libimagdiary/Cargo.toml @@ -18,6 +18,7 @@ chrono = "0.2" log = "0.3" semver = "0.5" toml = "0.4.*" +toml-query = "0.1.*" regex = "0.1" lazy_static = "0.2" itertools = "0.5" diff --git a/libimagdiary/src/config.rs b/libimagdiary/src/config.rs index b2e976a6..a341b24c 100644 --- a/libimagdiary/src/config.rs +++ b/libimagdiary/src/config.rs @@ -21,11 +21,13 @@ use toml::Value; use libimagrt::runtime::Runtime; +use toml_query::read::TomlValueReadExt; + pub fn get_default_diary_name(rt: &Runtime) -> Option { get_diary_config_section(rt) .and_then(|config| { - match config.lookup("default_diary") { - Some(&Value::String(ref s)) => Some(s.clone()), + match config.read(&String::from("default_diary")) { + Ok(&Value::String(ref s)) => Some(s.clone()), _ => None, } }) @@ -34,5 +36,5 @@ pub fn get_default_diary_name(rt: &Runtime) -> Option { 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")) + .and_then(|config| config.read(&String::from("diary")).ok()) } diff --git a/libimagdiary/src/lib.rs b/libimagdiary/src/lib.rs index f6756225..1dcd496f 100644 --- a/libimagdiary/src/lib.rs +++ b/libimagdiary/src/lib.rs @@ -38,6 +38,7 @@ extern crate chrono; #[macro_use] extern crate lazy_static; extern crate semver; extern crate toml; +extern crate toml_query; extern crate regex; extern crate itertools;