diff --git a/libimagannotation/src/annotateable.rs b/libimagannotation/src/annotateable.rs index 698773cb..8827916a 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>; + /// Check whether an entry is an annotation + fn is_annotation(&self) -> Result; + } impl Annotateable for Entry { @@ -66,5 +69,16 @@ impl Annotateable for Entry { }) } + fn is_annotation(&self) -> Result { + 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()), + }) + } + }