summaryrefslogtreecommitdiffstats
path: root/lib/entry
diff options
context:
space:
mode:
Diffstat (limited to 'lib/entry')
-rw-r--r--lib/entry/libimagentryannotation/Cargo.toml1
-rw-r--r--lib/entry/libimagentryannotation/src/annotateable.rs20
-rw-r--r--lib/entry/libimagentryannotation/src/annotation_fetcher.rs8
-rw-r--r--lib/entry/libimagentryannotation/src/lib.rs1
-rw-r--r--lib/entry/libimagentryfilter/Cargo.toml1
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs4
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs5
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs8
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs6
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs14
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs4
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs6
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs5
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs6
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs6
-rw-r--r--lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs6
-rw-r--r--lib/entry/libimagentryfilter/src/lib.rs1
-rw-r--r--lib/entry/libimagentrylink/Cargo.toml1
-rw-r--r--lib/entry/libimagentrylink/src/external.rs10
-rw-r--r--lib/entry/libimagentrylink/src/internal.rs32
-rw-r--r--lib/entry/libimagentrylink/src/lib.rs1
-rw-r--r--lib/entry/libimagentryref/Cargo.toml1
-rw-r--r--lib/entry/libimagentryref/src/flags.rs4
-rw-r--r--lib/entry/libimagentryref/src/lib.rs1
-rw-r--r--lib/entry/libimagentryref/src/reference.rs23
-rw-r--r--lib/entry/libimagentrytag/Cargo.toml1
-rw-r--r--lib/entry/libimagentrytag/src/lib.rs1
-rw-r--r--lib/entry/libimagentrytag/src/tagable.rs10
28 files changed, 109 insertions, 78 deletions
diff --git a/lib/entry/libimagentryannotation/Cargo.toml b/lib/entry/libimagentryannotation/Cargo.toml
index a0ceb99a..33666606 100644
--- a/lib/entry/libimagentryannotation/Cargo.toml
+++ b/lib/entry/libimagentryannotation/Cargo.toml
@@ -13,6 +13,7 @@ license = "LGPL-2.1"
uuid = { version = "0.3.1", features = ["v4"] }
lazy_static = "0.1.15"
toml = "^0.4"
+toml-query = "0.3.0"
libimagstore = { version = "0.4.0", path = "../../../lib/core/libimagstore" }
libimagerror = { version = "0.4.0", path = "../../../lib/core/libimagerror" }
diff --git a/lib/entry/libimagentryannotation/src/annotateable.rs b/lib/entry/libimagentryannotation/src/annotateable.rs
index 8827916a..4fb3589a 100644
--- a/lib/entry/libimagentryannotation/src/annotateable.rs
+++ b/lib/entry/libimagentryannotation/src/annotateable.rs
@@ -24,10 +24,12 @@ use toml::Value;
use libimagstore::store::Entry;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
-use libimagstore::toml_ext::TomlValueExt;
use libimagentrylink::internal::InternalLinker;
use libimagerror::into::IntoError;
+use toml_query::read::TomlValueReadExt;
+use toml_query::insert::TomlValueInsertExt;
+
use result::Result;
use error::AnnotationErrorKind as AEK;
use error::MapErrInto;
@@ -53,14 +55,8 @@ impl Annotateable for Entry {
.and_then(|mut anno| {
anno.get_header_mut()
.insert("annotation.is_annotation", Value::Boolean(true))
- .map_err_into(AEK::StoreWriteError)
- .and_then(|succeeded| {
- if succeeded {
- Ok(anno)
- } else {
- Err(AEK::HeaderWriteError.into_error())
- }
- })
+ .map_err_into(AEK::HeaderWriteError)
+ .map(|_| anno)
})
.and_then(|mut anno| {
anno.add_internal_link(self)
@@ -74,9 +70,9 @@ impl Annotateable for Entry {
.read("annotation.is_annotation")
.map_err_into(AEK::StoreReadError)
.and_then(|res| match res {
- Some(Value::Boolean(b)) => Ok(b),
- None => Ok(false),
- _ => Err(AEK::HeaderTypeError.into_error()),
+ Some(&Value::Boolean(b)) => Ok(b),
+ None => Ok(false),
+ _ => Err(AEK::HeaderTypeError.into_error()),
})
}
diff --git a/lib/entry/libimagentryannotation/src/annotation_fetcher.rs b/lib/entry/libimagentryannotation/src/annotation_fetcher.rs
index 18c4a8be..58b27170 100644
--- a/lib/entry/libimagentryannotation/src/annotation_fetcher.rs
+++ b/lib/entry/libimagentryannotation/src/annotation_fetcher.rs
@@ -68,7 +68,8 @@ impl<'a> AnnotationFetcher<'a> for Store {
pub mod iter {
use toml::Value;
- use libimagstore::toml_ext::TomlValueExt;
+ use toml_query::read::TomlValueReadExt;
+
use libimagerror::into::IntoError;
use libimagnotes::note::Note;
use libimagnotes::note::NoteIterator;
@@ -95,10 +96,9 @@ pub mod iter {
loop {
match self.0.next() {
Some(Ok(note)) => {
- let hdr = note.get_header().read("annotation.is_annotation");
- match hdr {
+ match note.get_header().read("annotation.is_annotation") {
Ok(None) => continue, // not an annotation
- Ok(Some(Value::Boolean(true))) => return Some(Ok(note)),
+ Ok(Some(&Value::Boolean(true))) => return Some(Ok(note)),
Ok(Some(_)) => return Some(Err(AEK::HeaderTypeError.into_error())),
Err(e) => return Some(Err(e).map_err_into(AEK::HeaderReadError)),
}
diff --git a/lib/entry/libimagentryannotation/src/lib.rs b/lib/entry/libimagentryannotation/src/lib.rs
index 0cb4e779..c84e342f 100644
--- a/lib/entry/libimagentryannotation/src/lib.rs
+++ b/lib/entry/libimagentryannotation/src/lib.rs
@@ -19,6 +19,7 @@
extern crate uuid;
extern crate toml;
+extern crate toml_query;
#[macro_use] extern crate libimagerror;
#[macro_use] extern crate libimagstore;
diff --git a/lib/entry/libimagentryfilter/Cargo.toml b/lib/entry/libimagentryfilter/Cargo.toml
index decdc730..ea4df09d 100644
--- a/lib/entry/libimagentryfilter/Cargo.toml
+++ b/lib/entry/libimagentryfilter/Cargo.toml
@@ -21,6 +21,7 @@ log = "0.3"
regex = "0.2"
semver = "0.5.*"
toml = "^0.4"
+toml-query = "0.3.0"
libimagstore = { version = "0.4.0", path = "../../../lib/core/libimagstore" }
libimagentrytag = { version = "0.4.0", path = "../../../lib/entry/libimagentrytag" }
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs
index f10f3d0f..e2051958 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/field_eq.rs
@@ -32,8 +32,8 @@ struct EqPred {
impl Predicate for EqPred {
- fn evaluate(&self, v: Value) -> bool {
- self.expected == v
+ fn evaluate(&self, v: &Value) -> bool {
+ self.expected == *v
}
}
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs
index 5fe672da..d793450a 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/field_exists.rs
@@ -18,11 +18,12 @@
//
use libimagstore::store::Entry;
-use libimagstore::toml_ext::TomlValueExt;
-use builtin::header::field_path::FieldPath;
+use toml_query::read::TomlValueReadExt;
use filters::filter::Filter;
+use builtin::header::field_path::FieldPath;
+
pub struct FieldExists {
header_field_path: FieldPath,
}
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs
index 799fee68..c6cdb624 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/field_grep.rs
@@ -33,10 +33,10 @@ struct EqGrep{
impl Predicate for EqGrep {
- fn evaluate(&self, v: Value) -> bool {
- match v {
- Value::String(s) => self.regex.captures(&s[..]).is_some(),
- _ => false,
+ fn evaluate(&self, v: &Value) -> bool {
+ match *v {
+ Value::String(ref s) => self.regex.captures(&s[..]).is_some(),
+ _ => false,
}
}
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs
index 2c1bcf89..6d50ddf7 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/field_gt.rs
@@ -32,17 +32,17 @@ struct EqGt {
impl Predicate for EqGt {
- fn evaluate(&self, v: Value) -> bool {
+ fn evaluate(&self, v: &Value) -> bool {
match self.comp {
Value::Integer(i) => {
- match v {
+ match *v {
Value::Integer(j) => i > j,
Value::Float(f) => (i as f64) > f,
_ => false,
}
},
Value::Float(f) => {
- match v {
+ match *v {
Value::Integer(i) => f > (i as f64),
Value::Float(d) => f > d,
_ => false,
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs
index 7a9c6521..57003e32 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/field_isempty.rs
@@ -18,7 +18,7 @@
//
use libimagstore::store::Entry;
-use libimagstore::toml_ext::TomlValueExt;
+use toml_query::read::TomlValueReadExt;
use builtin::header::field_path::FieldPath;
use filters::filter::Filter;
@@ -46,12 +46,12 @@ impl Filter<Entry> for FieldIsEmpty {
.read(&self.header_field_path[..])
.map(|v| {
match v {
- Some(Value::Array(a)) => a.is_empty(),
- Some(Value::String(s)) => s.is_empty(),
- Some(Value::Table(t)) => t.is_empty(),
- Some(Value::Boolean(_)) |
- Some(Value::Float(_)) |
- Some(Value::Integer(_)) => false,
+ Some(&Value::Array(ref a)) => a.is_empty(),
+ Some(&Value::String(ref s)) => s.is_empty(),
+ Some(&Value::Table(ref t)) => t.is_empty(),
+ Some(&Value::Boolean(_)) |
+ Some(&Value::Float(_)) |
+ Some(&Value::Integer(_)) => false,
_ => true,
}
})
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs
index 889c8321..471f772f 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/field_istype.rs
@@ -58,8 +58,8 @@ struct IsTypePred {
impl Predicate for IsTypePred {
- fn evaluate(&self, v: Value) -> bool {
- self.ty.matches(&v)
+ fn evaluate(&self, v: &Value) -> bool {
+ self.ty.matches(v)
}
}
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs
index 0316bf82..7a3e8445 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/field_lt.rs
@@ -32,17 +32,17 @@ struct EqLt {
impl Predicate for EqLt {
- fn evaluate(&self, v: Value) -> bool {
+ fn evaluate(&self, v: &Value) -> bool {
match self.comp {
Value::Integer(i) => {
- match v {
+ match *v {
Value::Integer(j) => i < j,
Value::Float(f) => (i as f64) < f,
_ => false,
}
},
Value::Float(f) => {
- match v {
+ match *v {
Value::Integer(i) => f < (i as f64),
Value::Float(d) => f < d,
_ => false,
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs b/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs
index 45aa332c..a167f762 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/field_predicate.rs
@@ -18,7 +18,8 @@
//
use libimagstore::store::Entry;
-use libimagstore::toml_ext::TomlValueExt;
+
+use toml_query::read::TomlValueReadExt;
use builtin::header::field_path::FieldPath;
use filters::filter::Filter;
@@ -26,7 +27,7 @@ use filters::filter::Filter;
use toml::Value;
pub trait Predicate {
- fn evaluate(&self, Value) -> bool;
+ fn evaluate(&self, &Value) -> bool;
}
/// Check whether certain header field in a entry is equal to a value
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs b/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs
index 1ca38f8b..5ba9f306 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/version/eq.rs
@@ -21,8 +21,8 @@ use semver::Version;
use toml::Value;
use libimagstore::store::Entry;
-use libimagstore::toml_ext::TomlValueExt;
+use toml_query::read::TomlValueReadExt;
use filters::filter::Filter;
pub struct VersionEq {
@@ -44,8 +44,8 @@ impl Filter<Entry> for VersionEq {
.read("imag.version")
.map(|val| {
val.map_or(false, |v| {
- match v {
- Value::String(s) => {
+ match *v {
+ Value::String(ref s) => {
match Version::parse(&s[..]) {
Ok(v) => v == self.version,
_ => false
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs b/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs
index 8e3873fb..edd0580f 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/version/gt.rs
@@ -21,8 +21,8 @@ use semver::Version;
use toml::Value;
use libimagstore::store::Entry;
-use libimagstore::toml_ext::TomlValueExt;
+use toml_query::read::TomlValueReadExt;
use filters::filter::Filter;
pub struct VersionGt {
@@ -44,8 +44,8 @@ impl Filter<Entry> for VersionGt {
.read("imag.version")
.map(|val| {
val.map_or(false, |v| {
- match v {
- Value::String(s) => {
+ match *v {
+ Value::String(ref s) => {
match Version::parse(&s[..]) {
Ok(v) => v > self.version,
_ => false
diff --git a/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs b/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs
index c475b436..629be9ae 100644
--- a/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs
+++ b/lib/entry/libimagentryfilter/src/builtin/header/version/lt.rs
@@ -21,8 +21,8 @@ use semver::Version;
use toml::Value;
use libimagstore::store::Entry;
-use libimagstore::toml_ext::TomlValueExt;
+use toml_query::read::TomlValueReadExt;
use filters::filter::Filter;
pub struct VersionLt {
@@ -44,8 +44,8 @@ impl Filter<Entry> for VersionLt {
.read("imag.version")
.map(|val| {
val.map_or(false, |v| {
- match v {
- Value::String(s) => {
+ match *v {
+ Value::String(ref s) => {
match Version::parse(&s[..]) {
Ok(v) => v < self.version,
_ => false
diff --git a/lib/entry/libimagentryfilter/src/lib.rs b/lib/entry/libimagentryfilter/src/lib.rs
index ad99db60..9f4fc84e 100644
--- a/lib/entry/libimagentryfilter/src/lib.rs
+++ b/lib/entry/libimagentryfilter/src/lib.rs
@@ -37,6 +37,7 @@ extern crate itertools;
extern crate regex;
extern crate semver;
extern crate toml;
+extern crate toml_query;
extern crate libimagstore;
extern crate libimagentrytag;
diff --git a/lib/entry/libimagentrylink/Cargo.toml b/lib/entry/libimagentrylink/Cargo.toml
index 32e86873..a0118b18 100644
--- a/lib/entry/libimagentrylink/Cargo.toml
+++ b/lib/entry/libimagentrylink/Cargo.toml
@@ -22,6 +22,7 @@ url = "1.2"
rust-crypto = "0.2"
env_logger = "0.3"
is-match = "0.1"
+toml-query = "0.3.0"
libimagstore = { version = "0.4.0", path = "../../../lib/core/libimagstore" }
libimagerror = { version = "0.4.0", path = "../../../lib/core/libimagerror" }
diff --git a/lib/entry/libimagentrylink/src/external.rs b/lib/entry/libimagentrylink/src/external.rs
index daed7a12..8ebd060d 100644
--- a/lib/entry/libimagentrylink/src/external.rs
+++ b/lib/entry/libimagentrylink/src/external.rs
@@ -39,9 +39,11 @@ use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;
-use libimagstore::toml_ext::TomlValueExt;
use libimagutil::debug_result::*;
+use toml_query::read::TomlValueReadExt;
+use toml_query::set::TomlValueSetExt;
+
use error::LinkError as LE;
use error::LinkErrorKind as LEK;
use error::MapErrInto;
@@ -73,7 +75,7 @@ impl<'a> Link<'a> {
.read("imag.content.url")
.ok()
.and_then(|opt| match opt {
- Some(Value::String(s)) => {
+ Some(&Value::String(ref s)) => {
debug!("Found url, parsing: {:?}", s);
Url::parse(&s[..]).ok()
},
@@ -87,7 +89,7 @@ impl<'a> Link<'a> {
.read("imag.content.url");
match opt {
- Ok(Some(Value::String(s))) => {
+ Ok(Some(&Value::String(ref s))) => {
Url::parse(&s[..])
.map(Some)
.map_err(|e| LE::new(LEK::EntryHeaderReadError, Some(Box::new(e))))
@@ -351,7 +353,7 @@ impl ExternalLinker for Entry {
let mut hdr = file.deref_mut().get_header_mut();
let mut table = match hdr.read("imag.content") {
- Ok(Some(Value::Table(table))) => table,
+ Ok(Some(&Value::Table(ref table))) => table.clone(),
Ok(Some(_)) => {
warn!("There is a value at 'imag.content' which is not a table.");
warn!("Going to override this value");
diff --git a/lib/entry/libimagentrylink/src/internal.rs b/lib/entry/libimagentrylink/src/internal.rs
index 62003777..8e33d8d8 100644
--- a/lib/entry/libimagentrylink/src/internal.rs
+++ b/lib/entry/libimagentrylink/src/internal.rs
@@ -25,9 +25,11 @@ use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;
use libimagstore::store::Entry;
use libimagstore::store::Result as StoreResult;
-use libimagstore::toml_ext::TomlValueExt;
use libimagerror::into::IntoError;
+use toml_query::read::TomlValueReadExt;
+use toml_query::set::TomlValueSetExt;
+
use error::LinkErrorKind as LEK;
use error::MapErrInto;
use result::Result;
@@ -388,7 +390,12 @@ pub mod iter {
impl InternalLinker for Entry {
fn get_internal_links(&self) -> Result<LinkIter> {
- process_rw_result(self.get_header().read("imag.links"))
+ let res = self
+ .get_header()
+ .read("imag.links")
+ .map_err_into(LEK::EntryHeaderReadError)
+ .map(|r| r.cloned());
+ process_rw_result(res)
}
/// Set the links in a header and return the old links, if any.
@@ -417,7 +424,11 @@ impl InternalLinker for Entry {
})
})
}));
- process_rw_result(self.get_header_mut().set("imag.links", Value::Array(new_links)))
+ let res = self
+ .get_header_mut()
+ .set("imag.links", Value::Array(new_links))
+ .map_err_into(LEK::EntryHeaderReadError);
+ process_rw_result(res)
}
fn add_internal_link(&mut self, link: &mut Entry) -> Result<()> {
@@ -485,7 +496,9 @@ fn rewrite_links<I: Iterator<Item = Link>>(header: &mut Value, links: I) -> Resu
}));
debug!("Setting new link array: {:?}", links);
- let process = header.set("imag.links", Value::Array(links));
+ let process = header
+ .set("imag.links", Value::Array(links))
+ .map_err_into(LEK::EntryHeaderReadError);
process_rw_result(process).map(|_| ())
}
@@ -509,12 +522,17 @@ fn add_foreign_link(target: &mut Entry, from: StoreId) -> Result<()> {
})
}));
debug!("Setting links in {:?}: {:?}", target.get_location(), links);
- process_rw_result(target.get_header_mut().set("imag.links", Value::Array(links)))
- .map(|_| ())
+
+ let res = target
+ .get_header_mut()
+ .set("imag.links", Value::Array(links))
+ .map_err_into(LEK::EntryHeaderReadError);
+
+ process_rw_result(res).map(|_| ())
})
}
-fn process_rw_result(links: StoreResult<Option<Value>>) -> Result<LinkIter> {
+fn process_rw_result(links: Result<Option<Value>>) -> Result<LinkIter> {
use std::path::PathBuf;
let links = match links {
diff --git a/lib/entry/libimagentrylink/src/lib.rs b/lib/entry/libimagentrylink/src/lib.rs
index 2ed8b6ba..059a5d45 100644
--- a/lib/entry/libimagentrylink/src/lib.rs
+++ b/lib/entry/libimagentrylink/src/lib.rs
@@ -34,6 +34,7 @@
extern crate itertools;
#[macro_use] extern crate log;
extern crate toml;
+extern crate toml_query;
extern crate semver;
extern crate url;
extern crate crypto;
diff --git a/lib/entry/libimagentryref/Cargo.toml b/lib/entry/libimagentryref/Cargo.toml
index 7b7763e8..a60b8c9c 100644
--- a/lib/entry/libimagentryref/Cargo.toml
+++ b/lib/entry/libimagentryref/Cargo.toml
@@ -21,6 +21,7 @@ semver = "0.5"
toml = "^0.4"
version = "2.0.1"
walkdir = "1.0.*"
+toml-query = "0.3.0"
libimagstore = { version = "0.4.0", path = "../../../lib/core/libimagstore" }
libimagerror = { version = "0.4.0", path = "../../../lib/core/libimagerror" }
diff --git a/lib/entry/libimagentryref/src/flags.rs b/lib/entry/libimagentryref/src/flags.rs
index 6ddf2990..b3b6851c 100644
--- a/lib/entry/libimagentryref/src/flags.rs
+++ b/lib/entry/libimagentryref/src/flags.rs
@@ -37,13 +37,13 @@ impl RefFlags {
/// It assumes that this is a Map with Key = <name of the setting> and Value = boolean.
pub fn read(v: &Value) -> Result<RefFlags> {
fn get_field(v: &Value, key: &str) -> Result<bool> {
- use libimagstore::toml_ext::TomlValueExt;
+ use toml_query::read::TomlValueReadExt;
use error::MapErrInto;
v.read(key)
.map_err_into(REK::HeaderTomlError)
.and_then(|toml| match toml {
- Some(Value::Boolean(b)) => Ok(b),
+ Some(&Value::Boolean(b)) => Ok(b),
Some(_) => Err(REK::HeaderTypeError.into()),
None => Err(REK::HeaderFieldMissingError.into()),
})
diff --git a/lib/entry/libimagentryref/src/lib.rs b/lib/entry/libimagentryref/src/lib.rs
index 86c187d0..6189a4e0 100644
--- a/lib/entry/libimagentryref/src/lib.rs
+++ b/lib/entry/libimagentryref/src/lib.rs
@@ -36,6 +36,7 @@ extern crate crypto;
extern crate itertools;
extern crate semver;
extern crate toml;
+extern crate toml_query;
extern crate version;
extern crate walkdir;
diff --git a/lib/entry/libimagentryref/src/reference.rs b/lib/entry/libimagentryref/src/reference.rs
index e860452e..81e991ca 100644
--- a/lib/entry/libimagentryref/src/reference.rs
+++ b/lib/entry/libimagentryref/src/reference.rs
@@ -33,10 +33,12 @@ use libimagstore::store::FileLockEntry;
use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;
use libimagstore::store::Store;
-use libimagstore::toml_ext::TomlValueExt;
use libimagerror::into::IntoError;
use toml::Value;
+use toml_query::read::TomlValueReadExt;
+use toml_query::set::TomlValueSetExt;
+use toml_query::insert::TomlValueInsertExt;
use error::RefErrorKind as REK;
use error::MapErrInto;
@@ -89,7 +91,7 @@ impl<'a> Ref<'a> {
fn read_reference(fle: &FileLockEntry<'a>) -> Result<PathBuf> {
match fle.get_header().read("ref.path") {
- Ok(Some(Value::String(s))) => Ok(PathBuf::from(s)),
+ Ok(Some(&Value::String(ref s))) => Ok(PathBuf::from(s)),
Ok(Some(_)) => Err(REK::HeaderTypeError.into_error()),
Ok(None) => Err(REK::HeaderFieldMissingError.into_error()),
Err(e) => Err(REK::StoreReadError.into_error_with_cause(Box::new(e))),
@@ -204,18 +206,17 @@ impl<'a> Ref<'a> {
match tpl {
&Some((ref s, ref v)) => {
match fle.get_header_mut().insert(s, v.clone()) {
- Ok(false) => {
- let e = REK::HeaderFieldAlreadyExistsError.into_error();
- let e = Box::new(e);
- let e = REK::HeaderFieldWriteError.into_error_with_cause(e);
- return Err(e);
+ Ok(None) => {
+ debug!("Header insert worked");
+ }
+ Ok(Some(val)) => {
+ debug!("Overwrote: {}, which was: {:?}", s, val);
},
Err(e) => {
let e = Box::new(e);
let e = REK::HeaderFieldWriteError.into_error_with_cause(e);
return Err(e);
},
- _ => (),
}
}
&None => {
@@ -274,7 +275,7 @@ impl<'a> Ref<'a> {
pub fn get_stored_hash_with_hasher<H: Hasher>(&self, h: &H) -> Result<String> {
match self.0.get_header().read(&format!("ref.content_hash.{}", h.hash_name())[..]) {
// content hash stored...
- Ok(Some(Value::String(s))) => Ok(s),
+ Ok(Some(&Value::String(ref s))) => Ok(s.clone()),
// content hash header field has wrong type
Ok(Some(_)) => Err(REK::HeaderTypeError.into_error()),
@@ -365,7 +366,7 @@ impl<'a> Ref<'a> {
.map_err(|e| REK::HeaderFieldReadError.into_error_with_cause(e))
.and_then(|ro| {
match ro {
- Some(Value::Boolean(b)) => Ok(b),
+ Some(&Value::Boolean(b)) => Ok(b),
Some(_) => Err(REK::HeaderTypeError.into_error()),
None => Err(REK::HeaderFieldMissingError.into_error()),
}
@@ -414,7 +415,7 @@ impl<'a> Ref<'a> {
/// Get the path of the file which is reffered to by this Ref
pub fn fs_file(&self) -> Result<PathBuf> {
match self.0.get_header().read("ref.path") {
- Ok(Some(Value::String(ref s))) => Ok(PathBuf::from(s)),
+ Ok(Some(&Value::String(ref s))) => Ok(PathBuf::from(s)),
Ok(Some(_)) => Err(REK::HeaderTypeError.into_error()),
Ok(None) => Err(REK::HeaderFieldMissingError.into_error()),
Err(e) => Err(REK::StoreReadError.into_error_with_cause(Box::new(e))),
diff --git a/lib/entry/libimagentrytag/Cargo.toml b/lib/entry/libimagentrytag/Cargo.toml
index a58b33d0..1732fb64 100644
--- a/lib/entry/libimagentrytag/Cargo.toml
+++ b/lib/entry/libimagentrytag/Cargo.toml
@@ -21,6 +21,7 @@ toml = "^0.4"
itertools = "0.5"
is-match = "0.1"
filters = "0.1"
+toml-query = "0.3.0"
libimagstore = { version = "0.4.0", path = "../../../lib/core/libimagstore" }
libimagerror = { version = "0.4.0", path = "../../../lib/core/libimagerror" }
diff --git a/lib/entry/libimagentrytag/src/lib.rs b/lib/entry/libimagentrytag/src/lib.rs
index bfc4d461..f50980d8 100644
--- a/lib/entry/libimagentrytag/src/lib.rs
+++ b/lib/entry/libimagentrytag/src/lib.rs
@@ -36,6 +36,7 @@ extern crate itertools;
#[macro_use] extern crate log;
extern crate regex;
extern crate toml;
+extern crate toml_query;
#[macro_use] extern crate is_match;
extern crate fil