Update toml-query: 0.2.0 -> 0.3.0

This commit is contained in:
Matthias Beyer 2017-07-09 21:51:26 +02:00
parent bddc79efaa
commit 218977ae17
3 changed files with 11 additions and 17 deletions

View file

@ -16,7 +16,7 @@ homepage = "http://imag-pim.org"
[dependencies]
log = "0.3"
toml = "0.4"
toml-query = "0.2"
toml-query = "0.3"
is-match = "0.1"
[dev-dependencies]

View file

@ -88,23 +88,16 @@ impl EntryCategory for Entry {
}
.map_err_into(CEK::HeaderReadError),
Ok(&Value::String(ref s)) => Ok(Some(s.clone().into())),
Ok(Some(&Value::String(ref s))) => Ok(Some(s.clone().into())),
Ok(None) => Err(CEK::StoreReadError.into_error()).map_err_into(CEK::HeaderReadError),
Ok(_) => Err(CEK::TypeError.into_error()).map_err_into(CEK::HeaderReadError),
}
}
fn has_category(&self) -> Result<bool> {
let res = self.get_header().read(&String::from("category.value"));
if res.is_err() {
let res = res.unwrap_err();
match res.kind() {
&TQEK::IdentifierNotFoundInDocument(_) => Ok(false),
_ => Err(res),
}
self.get_header().read(&String::from("category.value"))
.map_err_into(CEK::HeaderReadError)
} else {
Ok(true)
}
.map(|e| e.is_some())
}
}

View file

@ -198,9 +198,10 @@ mod tests {
assert!(header_field.is_ok(), format!("Expected Ok(_), got: {:?}", header_field));
let header_field = header_field.unwrap();
match *header_field {
Value::String(ref s) => assert_eq!(category_name, s),
_ => assert!(false, "Header field has wrong type"),
match header_field {
Some(&Value::String(ref s)) => assert_eq!(category_name, s),
Some(_) => assert!(false, "Header field has wrong type"),
None => assert!(false, "Header field not present"),
}
}
}
@ -228,7 +229,7 @@ fn represents_category(store: &Store, sid: StoreId, name: &str) -> Result<bool>
.read(&String::from(CATEGORY_REGISTER_NAME_FIELD_PATH))
.map_err_into(CEK::HeaderReadError)
{
Ok(&Value::String(ref s)) => Ok(s == name),
Ok(Some(&Value::String(ref s))) => Ok(s == name),
Ok(_) => Err(CEK::TypeError.into_error()),
Err(e) => Err(e).map_err_into(CEK::HeaderReadError),
}
@ -279,7 +280,7 @@ impl<'a> Iterator for CategoryNameIter<'a> {
.map_err_into(CEK::StoreReadError)
.and_then(|fle| fle.ok_or(CEK::StoreReadError.into_error()))
.and_then(|fle| match fle.get_header().read(&query) {
Ok(&Value::String(ref s)) => Ok(Category::from(s.clone())),
Ok(Some(&Value::String(ref s))) => Ok(Category::from(s.clone())),
Ok(_) => Err(CEK::TypeError.into_error()),
Err(e) => Err(e).map_err_into(CEK::HeaderReadError),
})