Struct stam::AnnotationData

source ·
pub struct AnnotationData { /* private fields */ }
Expand description

AnnotationData holds the actual content of an annotation; a key/value pair. (the term feature is regularly seen for this in certain annotation paradigms). Annotation Data is deliberately decoupled from the actual Annotation instances so multiple annotation instances can point to the same content without causing any overhead in storage. Moreover, it facilitates indexing and searching. The annotation data is part of an AnnotationDataSet, which effectively defines a certain user-defined vocabulary.

Once instantiated, instances of this type are, by design, largely immutable. The key and value can not be changed. Create a new AnnotationData and new Annotation for edits.

Implementations§

source§

impl AnnotationData

source

pub fn new(id: Option<String>, key: DataKeyHandle, value: DataValue) -> Self

Creates a new unbounded AnnotationData instance, you will likely never want to instantiate this directly, but via

source

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

Returns an Annotation data builder to build new annotationdata

source

pub fn key(&self) -> DataKeyHandle

source

pub fn value(&self) -> &DataValue

Get the value of this annotationdata. The value will be a DataValue instance. This will return an immutable reference. Note that there is no mutable variant nor a set_value(), values can deliberately only be set once at instantiation. Make a new AnnotationData if you want to change data.

source

pub fn to_json(&self, store: &AnnotationDataSet) -> Result<String, StamError>

Writes an Annotation to one big STAM JSON string, with appropriate formatting

source§

impl AnnotationData

source

pub fn test(&self, operator: &DataOperator<'_>) -> bool

Trait Implementations§

source§

impl Clone for AnnotationData

source§

fn clone(&self) -> AnnotationData

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 AnnotationData

source§

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

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

impl PartialEq<AnnotationData> for AnnotationData

source§

fn eq(&self, other: &AnnotationData) -> 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 Storable for AnnotationData

§

type HandleType = AnnotationDataHandle

§

type StoreType = AnnotationDataSet

source§

fn handle(&self) -> Option<AnnotationDataHandle>

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 id(&self) -> Option<&str>

Get the public ID
source§

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

Builder pattern to set the public Id
source§

fn set_handle(&mut self, intid: AnnotationDataHandle)

Set the internal ID. May only be called once (though currently not enforced).
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<AnnotationData> for AnnotationDataSet

source§

fn preremove(&mut self, handle: AnnotationDataHandle) -> 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<AnnotationData>

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

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

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

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

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<AnnotationDataHandle>>

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

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

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

fn store_typeinfo() -> &'static str

source§

fn inserted(&mut self, handle: AnnotationDataHandle) -> 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 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 AnnotationData

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