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.
This commit is contained in:
parent
00256effdb
commit
8ddb0f6c24
2 changed files with 5 additions and 4 deletions
|
@ -255,7 +255,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn get_entry_tags<'a>(entry: &'a FileLockEntry<'a>) -> TomlQueryResult<Option<&'a Value>> {
|
||||
entry.get_header().read(&"imag.tags".to_owned())
|
||||
entry.get_header().read(&"tag.values".to_owned())
|
||||
}
|
||||
|
||||
fn tags_toml_value<'a, I: IntoIterator<Item = &'static str>>(tags: I) -> Value {
|
||||
|
|
|
@ -49,7 +49,7 @@ pub trait Tagable {
|
|||
impl Tagable for Value {
|
||||
|
||||
fn get_tags(&self) -> Result<Vec<Tag>> {
|
||||
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<bool> {
|
||||
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());
|
||||
|
|
Loading…
Reference in a new issue