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

source

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

source

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()

source

pub fn builder() -> AnnotationBuilder<'a>

Returns an Annotation builder to build new annotations

source

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.

source

pub fn data_by_index( &self, index: usize ) -> Option<&(AnnotationDataSetHandle, AnnotationDataHandle)>

Returns data at specified index

source

pub fn len(&self) -> usize

Returns the number of annotation data items

source

pub fn target(&self) -> &Selector

Returns a reference to the selector that selects the target of this annotation

Trait Implementations§

source§

impl Clone for Annotation

source§

fn clone(&self) -> Annotation

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Annotation

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Annotation> for Annotation

source§

fn eq(&self, other: &Annotation) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SelfSelector for Annotation

source§

fn selector(&self) -> Result<Selector, StamError>

Returns a selector to this resource

source§

impl Storable for Annotation

§

type HandleType = AnnotationHandle

§

type StoreType = AnnotationStore

source§

fn id(&self) -> Option<&str>

Get the public ID
source§

fn handle(&self) -> Option<Self::HandleType>

Retrieve the internal (numeric) id. For any type T uses in 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)

Set the internal ID. May only be called once (though currently not enforced).
source§

fn with_id(self, id: String) -> Self

Builder pattern to set the public Id
source§

fn carries_id() -> bool

Does this type support an ID?
source§

fn handle_or_err(&self) -> Result<Self::HandleType, StamError>

Like Self::handle() but returns a StamError::Unbound error if there is no internal id.
source§

fn id_or_err(&self) -> Result<&str, StamError>

Like 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,

Returns a wrapped reference to this item and the store that owns it. This allows for some more introspection on the part of the item. reverse of StoreFor<T>::wrap()
source§

fn wrap_owned_in<'store>( self, store: &'store Self::StoreType ) -> Result<WrappedItem<'store, Self>, StamError>where Self: Sized,

Returns a wrapped reference to this item and the store that owns it. This allows for some more introspection on the part of the item. reverse of StoreFor<T>::wrap_owned()
source§

fn bound(&mut self)

Callback function that is called after an item is bound to a store
source§

fn generate_id(self, idmap: Option<&mut IdMap<Self::HandleType>>) -> Selfwhere Self: Sized,

Generate a random ID in a given idmap (adds it to the map and assigns it to the item)
source§

impl StoreFor<Annotation> for AnnotationStore

source§

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

source§

fn store(&self) -> &Store<Annotation>

Get a reference to the entire store for the associated type
source§

fn store_mut(&mut self) -> &mut Store<Annotation>

Get a mutable reference to the entire store for the associated type
source§

fn idmap(&self) -> Option<&IdMap<AnnotationHandle>>

Get a reference to the id map for the associated type, mapping global ids to internal ids
source§

fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationHandle>>

Get a mutable reference to the id map for the associated type, mapping global ids to internal ids
source§

fn store_typeinfo() -> &'static str

source§

fn inserted(&mut self, handle: AnnotationHandle) -> Result<(), StamError>

Called after an item was inserted to the store Allows the store to do further bookkeeping like updating relation maps
source§

fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>

Adds an item to the store. Returns a handle to it upon success.
source§

fn preinsert(&self, item: &mut T) -> Result<(), StamError>

Called prior to inserting an item into to the store If it returns an error, the insert will be cancelled. Allows for bookkeeping such as inheriting configuration parameters from parent to the item
source§

fn add(self, item: T) -> Result<Self, StamError>where Self: Sized,

source§

fn has<'a, 'b>(&'a self, item: &Item<'b, T>) -> bool

Returns true if the store has the item
source§

unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>

Get a reference to an item from the store, by handle, without checking validity. Read more
source§

fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>

Get a reference to an item from the store
source§

fn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>

Get a mutable reference to an item from the store by internal ID
source§

fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>

Removes an item by handle, returns an error if the item has dependencies and can’t be removed
source§

fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>

Resolves an ID to a handle You usually don’t want to call this directly
source§

fn owns(&self, item: &T) -> Option<bool>

Tests if the item is owner by the store, returns None if ownership is unknown
source§

fn iter<'a>(&'a self) -> StoreIter<'a, T> where T: Storable<StoreType = Self>,

Iterate over the store
source§

fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T>

Iterate over the store, mutably
source§

fn next_handle(&self) -> T::HandleType

Return the internal id that will be assigned for the next item to the store
source§

fn last_handle(&self) -> T::HandleType

Return the internal id that was assigned to last inserted item
source§

fn bind(&mut self, item: T) -> Result<T, StamError>

This binds an item to the store PRIOR to it being actually added You should never need to call this directly (it can only be called once per item anyway).
source§

fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,

Wraps the item in a smart pointer that also holds a reference to this store This method performs some extra checks to verify if the item is indeed owned by the store and returns an error if not.
source§

fn wrap_owned<'a>(&'a self, item: T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,

Wraps the item in a smart pointer that also holds a reference to this store Ownership is retained with this method, i.e. the store does NOT own the item.
source§

fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where Self: Sized,

Wraps the entire store along with a reference to self Low-level method that you won’t need
source§

impl TypeInfo for Annotation

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V