From 2bad2ef501fcf4fa1111e9fee74a2569636fdb3f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 3 May 2017 18:09:57 +0200 Subject: [PATCH] Adapt to use toml 0.4 --- libimagstore/src/store.rs | 6 +++--- libimagstore/src/toml_ext.rs | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 39f59788..ef5725f5 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -1252,7 +1252,7 @@ impl Entry { /// disk). pub fn to_str(&self) -> String { format!("---\n{header}---\n{content}", - header = ::toml::encode_str(&self.header), + header = ::toml::ser::to_string(&self.header).unwrap(), content = self.content) } @@ -1915,9 +1915,9 @@ mod store_hook_tests { use self::test_hook::TestHook; fn get_store_with_config() -> Store { - use toml::Parser; + use toml::de::from_str; - let cfg = Parser::new(mini_config()).parse().unwrap(); + let cfg : ::toml::Value = from_str(mini_config()).unwrap(); println!("Config parsed: {:?}", cfg); Store::new(PathBuf::from("/"), Some(cfg.get("store").cloned().unwrap())).unwrap() } diff --git a/libimagstore/src/toml_ext.rs b/libimagstore/src/toml_ext.rs index 1ac4cf11..9c0ae540 100644 --- a/libimagstore/src/toml_ext.rs +++ b/libimagstore/src/toml_ext.rs @@ -20,7 +20,7 @@ use std::result::Result as RResult; use std::collections::BTreeMap; -use toml::{Table, Value}; +use toml::Value; use store::Result; use error::StoreError as SE; @@ -28,6 +28,8 @@ use error::StoreErrorKind as SEK; use error::{ParserErrorKind, ParserError}; use libimagerror::into::IntoError; +type Table = BTreeMap; + pub trait TomlValueExt { fn insert_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result; fn set_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result>; @@ -378,11 +380,10 @@ impl Header for Value { } fn parse(s: &str) -> EntryResult { - use toml::Parser; + use toml::de::from_str; - let mut parser = Parser::new(s); - parser.parse() - .ok_or(ParserErrorKind::TOMLParserErrors.into()) + from_str(s) + .map_err(|_| ParserErrorKind::TOMLParserErrors.into()) .and_then(verify_header_consistency) .map(Value::Table) }