summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-08-26 17:53:08 +0200
committerMatthias Beyer <mail@beyermatthias.de>2017-08-28 12:22:37 +0200
commitc0c62bd1b5c5b9ece1d8289721dc8617987a7885 (patch)
tree34b1acf7872eb10db152c0c1a9bf96bf52027e4a /lib
parent3024fefcb9d338919e0a3b5b1b90fb77d2313330 (diff)
Change crates to use toml-query crate
Diffstat (limited to 'lib')
-rw-r--r--lib/core/libimagrt/Cargo.toml1
-rw-r--r--lib/core/libimagrt/src/configuration.rs7
-rw-r--r--lib/core/libimagrt/src/lib.rs1
-rw-r--r--lib/domain/libimagnotes/Cargo.toml1
-rw-r--r--lib/domain/libimagnotes/src/lib.rs1
-rw-r--r--lib/domain/libimagnotes/src/note.rs6
-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
34 files changed, 121 insertions, 83 deletions
diff --git a/lib/core/libimagrt/Cargo.toml b/lib/core/libimagrt/Cargo.toml
index 4f0f0863..0599e233 100644
--- a/lib/core/libimagrt/Cargo.toml
+++ b/lib/core/libimagrt/Cargo.toml
@@ -23,6 +23,7 @@ itertools = "0.5"
tempfile = "2.1"
ansi_term = "0.9"
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/core/libimagrt/src/configuration.rs b/lib/core/libimagrt/src/configuration.rs
index dcb3326b..bc3b52b4 100644
--- a/lib/core/libimagrt/src/configuration.rs
+++ b/lib/core/libimagrt/src/configuration.rs
@@ -133,7 +133,8 @@ impl Configuration {
use self::error::ConfigErrorKind as CEK;
use self::error::MapErrInto;
use libimagerror::into::IntoError;
- use libimagstore::toml_ext::TomlValueExt;
+
+ use toml_query::read::TomlValueReadExt;
v.into_iter()
.map(|s| { debug!("Trying to process '{}'", s); s })
@@ -170,10 +171,10 @@ impl Configuration {
/// Returns None if string cannot be converted.
///
/// Arrays and Tables are not supported and will yield `None`.
-fn into_value(value: Value, s: String) -> Option<Value> {
+fn into_value(value: &Value, s: String) -> Option<Value> {
use std::str::FromStr;
- match value {
+ match *value {
Value::String(_) => Some(Value::String(s)),
Value::Integer(_) => FromStr::from_str(&s[..]).ok().map(Value::Integer),
Value::Float(_) => FromStr::from_str(&s[..]).ok().map(Value::Float),
diff --git a/lib/core/libimagrt/src/lib.rs b/lib/core/libimagrt/src/lib.rs
index 55398013..a28b525f 100644
--- a/lib/core/libimagrt/src/lib.rs
+++ b/lib/core/libimagrt/src/lib.rs
@@ -42,6 +42,7 @@ extern crate ansi_term;
extern crate clap;
extern crate toml;
+extern crate toml_query;
#[macro_use] extern crate is_match;
extern crate libimagstore;
diff --git a/lib/domain/libimagnotes/Cargo.toml b/lib/domain/libimagnotes/Cargo.toml
index d3616cde..3b19375a 100644
--- a/lib/domain/libimagnotes/Cargo.toml
+++ b/lib/domain/libimagnotes/Cargo.toml
@@ -17,6 +17,7 @@ homepage = "http://imag-pim.org"
semver = "0.5"
log = "0.3"
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/domain/libimagnotes/src/lib.rs b/lib/domain/libimagnotes/src/lib.rs
index 10ef952b..3fa1f5d2 100644
--- a/lib/domain/libimagnotes/src/lib.rs
+++ b/lib/domain/libimagnotes/src/lib.rs
@@ -36,6 +36,7 @@
#[macro_use] extern crate log;
extern crate semver;
extern crate toml;
+extern crate toml_query;
extern crate libimagrt;
#[macro_use] extern crate libimagstore;
diff --git a/lib/domain/libimagnotes/src/note.rs b/lib/domain/libimagnotes/src/note.rs
index cc50bab8..74991146 100644
--- a/lib/domain/libimagnotes/src/note.rs
+++ b/lib/domain/libimagnotes/src/note.rs
@@ -30,7 +30,9 @@ use libimagstore::storeid::StoreId;
use libimagstore::storeid::StoreIdIterator;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
-use libimagstore::toml_ext::TomlValueExt;
+
+use toml_query::read::TomlValueReadExt;
+use toml_query::set::TomlValueSetExt;
use module_path::ModuleEntryPath;
use result::Result;
@@ -92,7 +94,7 @@ impl<'a> Note<'a> {
pub fn get_name(&self) -> Result<String> {
let header = self.entry.get_header();
match header.read("note.name") {
- Ok(Some(Value::String(s))) => Ok(String::from(s)),
+ Ok(Some(&Value::String(ref s))) => Ok(s.clone()),
Ok(_) => {
let e = NE::new(NEK::HeaderTypeError, None);
Err(NE::new(NEK::StoreReadError, Some(Box::new(e))))
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/