Merge pull request #983 from matthiasbeyer/libimagannotation/add-is_annotation

Libimagannotation/add is annotation
This commit is contained in:
Matthias Beyer 2017-06-29 14:52:27 +02:00 committed by GitHub
commit c71b70702c
1 changed files with 14 additions and 0 deletions

View File

@ -40,6 +40,9 @@ pub trait Annotateable {
/// A new annotation also has the field `annotation.is_annotation` set to `true`.
fn annotate<'a>(&mut self, store: &'a Store, ann_name: &str) -> Result<FileLockEntry<'a>>;
/// Check whether an entry is an annotation
fn is_annotation(&self) -> Result<bool>;
}
impl Annotateable for Entry {
@ -66,5 +69,16 @@ impl Annotateable for Entry {
})
}
fn is_annotation(&self) -> Result<bool> {
self.get_header()
.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()),
})
}
}