Adapt to use toml 0.4

This commit is contained in:
Matthias Beyer 2017-05-03 18:09:57 +02:00
parent 585b5ffad6
commit 2bad2ef501
2 changed files with 9 additions and 8 deletions

View file

@ -1252,7 +1252,7 @@ impl Entry {
/// disk). /// disk).
pub fn to_str(&self) -> String { pub fn to_str(&self) -> String {
format!("---\n{header}---\n{content}", format!("---\n{header}---\n{content}",
header = ::toml::encode_str(&self.header), header = ::toml::ser::to_string(&self.header).unwrap(),
content = self.content) content = self.content)
} }
@ -1915,9 +1915,9 @@ mod store_hook_tests {
use self::test_hook::TestHook; use self::test_hook::TestHook;
fn get_store_with_config() -> Store { 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); println!("Config parsed: {:?}", cfg);
Store::new(PathBuf::from("/"), Some(cfg.get("store").cloned().unwrap())).unwrap() Store::new(PathBuf::from("/"), Some(cfg.get("store").cloned().unwrap())).unwrap()
} }

View file

@ -20,7 +20,7 @@
use std::result::Result as RResult; use std::result::Result as RResult;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use toml::{Table, Value}; use toml::Value;
use store::Result; use store::Result;
use error::StoreError as SE; use error::StoreError as SE;
@ -28,6 +28,8 @@ use error::StoreErrorKind as SEK;
use error::{ParserErrorKind, ParserError}; use error::{ParserErrorKind, ParserError};
use libimagerror::into::IntoError; use libimagerror::into::IntoError;
type Table = BTreeMap<String, Value>;
pub trait TomlValueExt { pub trait TomlValueExt {
fn insert_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result<bool>; fn insert_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result<bool>;
fn set_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result<Option<Value>>; fn set_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result<Option<Value>>;
@ -378,11 +380,10 @@ impl Header for Value {
} }
fn parse(s: &str) -> EntryResult<Value> { fn parse(s: &str) -> EntryResult<Value> {
use toml::Parser; use toml::de::from_str;
let mut parser = Parser::new(s); from_str(s)
parser.parse() .map_err(|_| ParserErrorKind::TOMLParserErrors.into())
.ok_or(ParserErrorKind::TOMLParserErrors.into())
.and_then(verify_header_consistency) .and_then(verify_header_consistency)
.map(Value::Table) .map(Value::Table)
} }