Struct stam::Annotation
source · pub struct Annotation { /* private fields */ }Expand description
Annotation represents a particular instance of annotation and is the central
concept of the model. They can be considered the primary nodes of the graph model. The
instance of annotation is strictly decoupled from the data or key/value of the
annotation (AnnotationData). After all, multiple instances can be annotated
with the same label (multiple annotations may share the same annotation data).
Moreover, an Annotation can have multiple annotation data associated.
The result is that multiple annotations with the exact same content require less storage
space, and searching and indexing is facilitated.
Implementations§
source§impl Annotation
impl Annotation
sourcepub fn to_json_string(
&self,
store: &AnnotationStore
) -> Result<String, StamError>
pub fn to_json_string( &self, store: &AnnotationStore ) -> Result<String, StamError>
Writes an Annotation to one big STAM JSON string, with appropriate formatting
source§impl<'a> Annotation
impl<'a> Annotation
sourcepub fn new(
id: Option<String>,
target: Selector,
data: Vec<(AnnotationDataSetHandle, AnnotationDataHandle)>
) -> Self
pub fn new( id: Option<String>, target: Selector, data: Vec<(AnnotationDataSetHandle, AnnotationDataHandle)> ) -> Self
Create a new unbounded Annotation instance, you will likely want to use BuildAnnotation::new() instead and pass it to AnnotationStore.build()
sourcepub fn builder() -> AnnotationBuilder<'a>
pub fn builder() -> AnnotationBuilder<'a>
Returns an Annotation builder to build new annotations
sourcepub fn data(
&'a self
) -> Iter<'a, (AnnotationDataSetHandle, AnnotationDataHandle)>
pub fn data( &'a self ) -> Iter<'a, (AnnotationDataSetHandle, AnnotationDataHandle)>
Iterate over the annotation data, returns tuples of internal IDs for (annotationset,annotationdata)
For a higher-level method, use WrappedItem<Annotation>::data() instead.
sourcepub fn data_by_index(
&self,
index: usize
) -> Option<&(AnnotationDataSetHandle, AnnotationDataHandle)>
pub fn data_by_index( &self, index: usize ) -> Option<&(AnnotationDataSetHandle, AnnotationDataHandle)>
Returns data at specified index
Trait Implementations§
source§impl Clone for Annotation
impl Clone for Annotation
source§fn clone(&self) -> Annotation
fn clone(&self) -> Annotation
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Annotation
impl Debug for Annotation
source§impl PartialEq<Annotation> for Annotation
impl PartialEq<Annotation> for Annotation
source§fn eq(&self, other: &Annotation) -> bool
fn eq(&self, other: &Annotation) -> bool
self and other values to be equal, and is used
by ==.source§impl SelfSelector for Annotation
impl SelfSelector for Annotation
source§impl Storable for Annotation
impl Storable for Annotation
type HandleType = AnnotationHandle
type StoreType = AnnotationStore
source§fn handle(&self) -> Option<Self::HandleType>
fn handle(&self) -> Option<Self::HandleType>
StoreFor<T>, this may be None only in the initial
stage when it is still unbounded to a store.source§fn set_handle(&mut self, handle: Self::HandleType)
fn set_handle(&mut self, handle: Self::HandleType)
source§fn carries_id() -> bool
fn carries_id() -> bool
source§fn handle_or_err(&self) -> Result<Self::HandleType, StamError>
fn handle_or_err(&self) -> Result<Self::HandleType, StamError>
Self::handle() but returns a StamError::Unbound error if there is no internal id.source§fn id_or_err(&self) -> Result<&str, StamError>
fn id_or_err(&self) -> Result<&str, StamError>
Self::id() but returns a StamError::NoIdError error if there is no internal id.source§fn wrap_in<'store>(
&'store self,
store: &'store Self::StoreType
) -> Result<WrappedItem<'store, Self>, StamError>where
Self: Sized,
fn wrap_in<'store>( &'store self, store: &'store Self::StoreType ) -> Result<WrappedItem<'store, Self>, StamError>where Self: Sized,
StoreFor<T>::wrap()source§fn wrap_owned_in<'store>(
self,
store: &'store Self::StoreType
) -> Result<WrappedItem<'store, Self>, StamError>where
Self: Sized,
fn wrap_owned_in<'store>( self, store: &'store Self::StoreType ) -> Result<WrappedItem<'store, Self>, StamError>where Self: Sized,
StoreFor<T>::wrap_owned()source§fn generate_id(self, idmap: Option<&mut IdMap<Self::HandleType>>) -> Selfwhere
Self: Sized,
fn generate_id(self, idmap: Option<&mut IdMap<Self::HandleType>>) -> Selfwhere Self: Sized,
source§impl StoreFor<Annotation> for AnnotationStore
impl StoreFor<Annotation> for AnnotationStore
source§fn preremove(&mut self, handle: AnnotationHandle) -> Result<(), StamError>
fn preremove(&mut self, handle: AnnotationHandle) -> Result<(), StamError>
called before the item is removed from the store updates the relation maps, no need to call manually