Adapt to use toml 0.4
This commit is contained in:
parent
585b5ffad6
commit
2bad2ef501
2 changed files with 9 additions and 8 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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<String, Value>;
|
||||
|
||||
pub trait TomlValueExt {
|
||||
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>>;
|
||||
|
@ -378,11 +380,10 @@ impl Header for Value {
|
|||
}
|
||||
|
||||
fn parse(s: &str) -> EntryResult<Value> {
|
||||
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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue