Init the header with default values
This commit is contained in:
parent
38292ea8cb
commit
796cd01343
1 changed files with 18 additions and 2 deletions
|
@ -2,7 +2,8 @@ use std::collections::BTreeMap;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::result::Result as RResult;
|
use std::result::Result as RResult;
|
||||||
|
|
||||||
use toml::{Table, Value};
|
use toml::{Array, Table, Value};
|
||||||
|
use version;
|
||||||
|
|
||||||
use self::error::ParserErrorKind;
|
use self::error::ParserErrorKind;
|
||||||
use self::error::ParserError;
|
use self::error::ParserError;
|
||||||
|
@ -97,7 +98,7 @@ impl EntryHeader {
|
||||||
*/
|
*/
|
||||||
pub fn new() -> EntryHeader {
|
pub fn new() -> EntryHeader {
|
||||||
EntryHeader {
|
EntryHeader {
|
||||||
toml: BTreeMap::new(),
|
toml: build_default_header(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,3 +290,18 @@ mod test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_default_header() -> BTreeMap<String, Value> {
|
||||||
|
let mut m = BTreeMap::new();
|
||||||
|
|
||||||
|
m.insert(String::from("imag"), {
|
||||||
|
let mut imag_map = BTreeMap::<String, Value>::new();
|
||||||
|
|
||||||
|
imag_map.insert(String::from("version"), Value::String(version!()));
|
||||||
|
imag_map.insert(String::from("links"), Value::Array(vec![]));
|
||||||
|
|
||||||
|
Value::Table(imag_map)
|
||||||
|
});
|
||||||
|
|
||||||
|
m
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue