From 8ddb0f6c24b55ede43ca2b523c44b9e48be11b70 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Sep 2017 19:46:08 +0200 Subject: [PATCH] Do not use "imag" namespace in header This change switches the header location for the tagging information from "imag.tags" to "tag.values". "tags" is not used because non-tables are not allowed at the top level of the header. Tests are adapted. --- bin/core/imag-tag/src/main.rs | 2 +- lib/entry/libimagentrytag/src/tagable.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/core/imag-tag/src/main.rs b/bin/core/imag-tag/src/main.rs index f1dd010c..8a48f605 100644 --- a/bin/core/imag-tag/src/main.rs +++ b/bin/core/imag-tag/src/main.rs @@ -255,7 +255,7 @@ mod tests { } fn get_entry_tags<'a>(entry: &'a FileLockEntry<'a>) -> TomlQueryResult> { - entry.get_header().read(&"imag.tags".to_owned()) + entry.get_header().read(&"tag.values".to_owned()) } fn tags_toml_value<'a, I: IntoIterator>(tags: I) -> Value { diff --git a/lib/entry/libimagentrytag/src/tagable.rs b/lib/entry/libimagentrytag/src/tagable.rs index 65c3275d..7b0e8135 100644 --- a/lib/entry/libimagentrytag/src/tagable.rs +++ b/lib/entry/libimagentrytag/src/tagable.rs @@ -49,7 +49,7 @@ pub trait Tagable { impl Tagable for Value { fn get_tags(&self) -> Result> { - let tags = try!(self.read("imag.tags").chain_err(|| TagErrorKind::HeaderReadError)); + let tags = try!(self.read("tag.values").chain_err(|| TagErrorKind::HeaderReadError)); match tags { Some(&Value::Array(ref tags)) => { @@ -85,7 +85,8 @@ impl Tagable for Value { } let a = ts.iter().unique().map(|t| Value::String(t.clone())).collect(); - self.set("imag.tags", Value::Array(a)) + debug!("Setting tags = {:?}", a); + self.set("tags", Value::Array(a)) .map(|_| ()) .chain_err(|| TagErrorKind::HeaderWriteError) } @@ -119,7 +120,7 @@ impl Tagable for Value { } fn has_tag(&self, t: TagSlice) -> Result { - let tags = try!(self.read("imag.tags").chain_err(|| TagErrorKind::HeaderReadError)); + let tags = try!(self.read("tag.values").chain_err(|| TagErrorKind::HeaderReadError)); if !tags.iter().all(|t| is_match!(*t, &Value::String(_))) { return Err(TagErrorKind::TagTypeError.into());