summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-06-29 14:52:27 +0200
committerGitHub <noreply@github.com>2017-06-29 14:52:27 +0200
commitc71b70702c30f587272fc2dbb20344bbcdeac872 (patch)
treee08116cce36c78d5930710cd2429a295080b90cc
parent7dea53c6c00ad615ffcfb372859fcd61d08c4a21 (diff)
parentfdee97c9a19cc7b3b64ca3b67fbe873ae9278c27 (diff)
downloadimag-c71b70702c30f587272fc2dbb20344bbcdeac872.zip
imag-c71b70702c30f587272fc2dbb20344bbcdeac872.tar.gz
Merge pull request #983 from matthiasbeyer/libimagannotation/add-is_annotation
Libimagannotation/add is annotation
-rw-r--r--libimagannotation/src/annotateable.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/libimagannotation/src/annotateable.rs b/libimagannotation/src/annotateable.rs
index 698773c..8827916 100644
--- a/libimagannotation/src/annotateable.rs
+++ b/libimagannotation/src/annotateable.rs
@@ -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()),
+ })
+ }
+
}