Struct stam::AnnotationDataSet
source · pub struct AnnotationDataSet { /* private fields */ }Expand description
An AnnotationDataSet stores the keys DataKey and values
AnnotationData (which in turn encapsulates DataValue) that are used by annotations.
It effectively defines a certain vocabulary, i.e. key/value pairs.
The AnnotationDataSet does not store the crate::annotation::Annotation instances themselves, those are in
the AnnotationStore. The datasets themselves are also held by the AnnotationStore.
Implementations§
source§impl AnnotationDataSet
impl AnnotationDataSet
pub fn new(config: Config) -> Self
sourcepub fn builder<'a>() -> AnnotationDataSetBuilder<'a>
pub fn builder<'a>() -> AnnotationDataSetBuilder<'a>
Returns an Annotation dataset builder to build new annotation datasets
sourcepub fn with_file(
self,
filename: &str,
config: Config
) -> Result<Self, StamError>
pub fn with_file( self, filename: &str, config: Config ) -> Result<Self, StamError>
Loads an AnnotationDataSet from file (STAM JSON or other supported format) and merges it into the current one. For STAM JSON, the file must contain a single object which has “@type”: “AnnotationDataSet” The ID will be ignored (existing one takes precendence).
sourcepub fn from_file(filename: &str, config: Config) -> Result<Self, StamError>
pub fn from_file(filename: &str, config: Config) -> Result<Self, StamError>
Loads an AnnotationDataSet from file (STAM JSON or other supported format). For STAM JSON, the file must contain a single object which has “@type”: “AnnotationDataSet”
sourcepub fn merge_from_builder(
&mut self,
builder: AnnotationDataSetBuilder<'_>
) -> Result<&mut Self, StamError>
pub fn merge_from_builder( &mut self, builder: AnnotationDataSetBuilder<'_> ) -> Result<&mut Self, StamError>
Merge another AnnotationDataSet, represented by an AnnotationDataSetBuilder, into this one.
It’s a fairly low-level function which you often don’t need directly, use AnnotationDataSet.with_file() instead.
sourcepub fn with_data(
self,
id: Item<'_, AnnotationData>,
key: Item<'_, DataKey>,
value: DataValue
) -> Result<Self, StamError>
pub fn with_data( self, id: Item<'_, AnnotationData>, key: Item<'_, DataKey>, value: DataValue ) -> Result<Self, StamError>
Adds new AnnotationData to the dataset, this should be
Note: if you don’t want to set an ID (first argument), you can just just pass “”.into()
sourcepub fn data_by_value(
&self,
key: Item<'_, DataKey>,
value: &DataValue
) -> Option<&AnnotationData>
pub fn data_by_value( &self, key: Item<'_, DataKey>, value: &DataValue ) -> Option<&AnnotationData>
Finds the [AnnotationData'] in the annotation dataset. Returns one match. This is a low level method, use the similar [WrappedItem
sourcepub fn insert_data<'a>(
&mut self,
id: Item<'a, AnnotationData>,
key: Item<'a, DataKey>,
value: DataValue,
safety: bool
) -> Result<AnnotationDataHandle, StamError>
pub fn insert_data<'a>( &mut self, id: Item<'a, AnnotationData>, key: Item<'a, DataKey>, value: DataValue, safety: bool ) -> Result<AnnotationDataHandle, StamError>
Adds new AnnotationData to the dataset. Use [Self.with_data()] instead if you are using a regular builder pattern.
If the data already exists, this returns a handle to the existing data and inserts nothing new.
If the data is new, it returns a handle to the new data.
Note: if you don’t want to set an ID (first argument), you can just pass AnyId::None or “”.into()
sourcepub fn build_insert_data(
&mut self,
dataitem: AnnotationDataBuilder<'_>,
safety: bool
) -> Result<AnnotationDataHandle, StamError>
pub fn build_insert_data( &mut self, dataitem: AnnotationDataBuilder<'_>, safety: bool ) -> Result<AnnotationDataHandle, StamError>
Build and insert data into the dataset, similar to [Self.insert_data()] and [Self.with_data()], but takes a prepared AnnotationDataBuilder instead.
sourcepub fn data(&self) -> StoreIter<'_, AnnotationData> ⓘ
pub fn data(&self) -> StoreIter<'_, AnnotationData> ⓘ
Returns an iterator over all the data (AnnotationData) in this set, the iterator returns references as [WrappedItem<AnnotationData].
sourcepub fn keys(&self) -> StoreIter<'_, DataKey> ⓘ
pub fn keys(&self) -> StoreIter<'_, DataKey> ⓘ
Returns an iterator over all the keys (DataKey) in this set, the iterator in returns references as WrappedItem<DataKey>
sourcepub fn key(&self, key: &Item<'_, DataKey>) -> Option<WrappedItem<'_, DataKey>>
pub fn key(&self, key: &Item<'_, DataKey>) -> Option<WrappedItem<'_, DataKey>>
Retrieve a key in this set
sourcepub fn annotationdata<'a>(
&'a self,
annotationdata: &Item<'_, AnnotationData>
) -> Option<WrappedItem<'a, AnnotationData>>
pub fn annotationdata<'a>( &'a self, annotationdata: &Item<'_, AnnotationData> ) -> Option<WrappedItem<'a, AnnotationData>>
Retrieve a AnnotationData in this set
Returns a reference to AnnotationData that is wrapped in a fat pointer
(WrappedItem<AnnotationData>) that also contains reference to the store and which is
immediately implements various methods for working with the type. If you need a more
performant low-level method, use StoreFor<T>::get() instead.
sourcepub fn data_by_key(
&self,
key: &Item<'_, DataKey>
) -> Option<&Vec<AnnotationDataHandle>>
pub fn data_by_key( &self, key: &Item<'_, DataKey> ) -> Option<&Vec<AnnotationDataHandle>>
Returns data by key, does a lookup in the reverse index and returns a reference to it.
This is a low-level method. use [WrappedItem<DataKey>.data()] instead.
sourcepub fn keys_len(&self) -> usize
pub fn keys_len(&self) -> usize
Writes a //Returns the number of keys in the store (deletions are not substracted)
pub fn data_len(&self) -> usize
Trait Implementations§
source§impl AssociatedFile for AnnotationDataSet
impl AssociatedFile for AnnotationDataSet
source§fn filename(&self) -> Option<&str>
fn filename(&self) -> Option<&str>
Get the filename for stand-off file specified using @include (if any)
source§fn set_filename(&mut self, filename: &str) -> &mut Self
fn set_filename(&mut self, filename: &str) -> &mut Self
Get the filename for stand-off file specified using @include (if any)
fn with_filename(self, filename: &str) -> Selfwhere Self: Sized,
source§fn filename_without_extension(&self) -> Option<&str>
fn filename_without_extension(&self) -> Option<&str>
source§fn filename_without_workdir(&self) -> Option<&str>
fn filename_without_workdir(&self) -> Option<&str>
source§impl Clone for AnnotationDataSet
impl Clone for AnnotationDataSet
source§fn clone(&self) -> AnnotationDataSet
fn clone(&self) -> AnnotationDataSet
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Configurable for AnnotationDataSet
impl Configurable for AnnotationDataSet
source§impl Debug for AnnotationDataSet
impl Debug for AnnotationDataSet
source§impl Default for AnnotationDataSet
impl Default for AnnotationDataSet
source§impl<'de> Deserialize<'de> for AnnotationDataSet
impl<'de> Deserialize<'de> for AnnotationDataSet
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<'j> FromJson<'j> for AnnotationDataSet
impl<'j> FromJson<'j> for AnnotationDataSet
source§impl PartialEq<AnnotationDataSet> for AnnotationDataSet
impl PartialEq<AnnotationDataSet> for AnnotationDataSet
source§fn eq(&self, other: &AnnotationDataSet) -> bool
fn eq(&self, other: &AnnotationDataSet) -> bool
self and other values to be equal, and is used
by ==.source§impl SelfSelector for AnnotationDataSet
impl SelfSelector for AnnotationDataSet
source§impl Serialize for AnnotationDataSet
impl Serialize for AnnotationDataSet
source§impl Storable for AnnotationDataSet
impl Storable for AnnotationDataSet
source§fn bound(&mut self)
fn bound(&mut self)
Sets the ownership of all items in the store This ensure the part_of_set relation (backreference) is set right.
type HandleType = AnnotationDataSetHandle
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: AnnotationDataSetHandle)
fn set_handle(&mut self, handle: AnnotationDataSetHandle)
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<AnnotationData> for AnnotationDataSet
impl StoreFor<AnnotationData> for AnnotationDataSet
source§fn preremove(&mut self, handle: AnnotationDataHandle) -> Result<(), StamError>
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>
fn store(&self) -> &Store<AnnotationData>
source§fn store_mut(&mut self) -> &mut Store<AnnotationData>
fn store_mut(&mut self) -> &mut Store<AnnotationData>
source§fn idmap(&self) -> Option<&IdMap<AnnotationDataHandle>>
fn idmap(&self) -> Option<&IdMap<AnnotationDataHandle>>
source§fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationDataHandle>>
fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationDataHandle>>
source§fn owns(&self, item: &AnnotationData) -> Option<bool>
fn owns(&self, item: &AnnotationData) -> Option<bool>
fn store_typeinfo() -> &'static str
source§fn inserted(&mut self, handle: AnnotationDataHandle) -> Result<(), StamError>
fn inserted(&mut self, handle: AnnotationDataHandle) -> Result<(), StamError>
source§fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
source§fn preinsert(&self, item: &mut T) -> Result<(), StamError>
fn preinsert(&self, item: &mut T) -> Result<(), StamError>
fn add(self, item: T) -> Result<Self, StamError>where Self: Sized,
source§unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
source§fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>
fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>
source§fn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>
fn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>
source§fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
source§fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
source§fn iter<'a>(&'a self) -> StoreIter<'a, T> ⓘwhere
T: Storable<StoreType = Self>,
fn iter<'a>(&'a self) -> StoreIter<'a, T> ⓘwhere T: Storable<StoreType = Self>,
source§fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
source§fn next_handle(&self) -> T::HandleType
fn next_handle(&self) -> T::HandleType
source§fn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
source§fn bind(&mut self, item: T) -> Result<T, StamError>
fn bind(&mut self, item: T) -> Result<T, StamError>
source§fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where
T: Storable<StoreType = Self>,
fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,
source§fn wrap_owned<'a>(&'a self, item: T) -> Result<WrappedItem<'_, T>, StamError>where
T: Storable<StoreType = Self>,
fn wrap_owned<'a>(&'a self, item: T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,
source§fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where
Self: Sized,
fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where Self: Sized,
source§impl StoreFor<AnnotationDataSet> for AnnotationStore
impl StoreFor<AnnotationDataSet> for AnnotationStore
source§fn preinsert(&self, item: &mut AnnotationDataSet) -> Result<(), StamError>
fn preinsert(&self, item: &mut AnnotationDataSet) -> 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 preremove(
&mut self,
handle: AnnotationDataSetHandle
) -> Result<(), StamError>
fn preremove( &mut self, handle: AnnotationDataSetHandle ) -> 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<AnnotationDataSet>
fn store(&self) -> &Store<AnnotationDataSet>
source§fn store_mut(&mut self) -> &mut Store<AnnotationDataSet>
fn store_mut(&mut self) -> &mut Store<AnnotationDataSet>
source§fn idmap(&self) -> Option<&IdMap<AnnotationDataSetHandle>>
fn idmap(&self) -> Option<&IdMap<AnnotationDataSetHandle>>
source§fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationDataSetHandle>>
fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationDataSetHandle>>
fn store_typeinfo() -> &'static str
source§fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
source§fn inserted(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn inserted(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn add(self, item: T) -> Result<Self, StamError>where Self: Sized,
source§unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
source§fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>
fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>
source§fn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>
fn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>
source§fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
source§fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
source§fn owns(&self, item: &T) -> Option<bool>
fn owns(&self, item: &T) -> Option<bool>
source§fn iter<'a>(&'a self) -> StoreIter<'a, T> ⓘwhere
T: Storable<StoreType = Self>,
fn iter<'a>(&'a self) -> StoreIter<'a, T> ⓘwhere T: Storable<StoreType = Self>,
source§fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
source§fn next_handle(&self) -> T::HandleType
fn next_handle(&self) -> T::HandleType
source§fn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
source§fn bind(&mut self, item: T) -> Result<T, StamError>
fn bind(&mut self, item: T) -> Result<T, StamError>
source§fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where
T: Storable<StoreType = Self>,
fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,
source§fn wrap_owned<'a>(&'a self, item: T) -> Result<WrappedItem<'_, T>, StamError>where
T: Storable<StoreType = Self>,
fn wrap_owned<'a>(&'a self, item: T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,
source§fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where
Self: Sized,
fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where Self: Sized,
source§impl StoreFor<DataKey> for AnnotationDataSet
impl StoreFor<DataKey> for AnnotationDataSet
source§fn preremove(&mut self, handle: DataKeyHandle) -> Result<(), StamError>
fn preremove(&mut self, handle: DataKeyHandle) -> 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<DataKey>
fn store(&self) -> &Store<DataKey>
source§fn store_mut(&mut self) -> &mut Store<DataKey>
fn store_mut(&mut self) -> &mut Store<DataKey>
source§fn idmap(&self) -> Option<&IdMap<DataKeyHandle>>
fn idmap(&self) -> Option<&IdMap<DataKeyHandle>>
source§fn idmap_mut(&mut self) -> Option<&mut IdMap<DataKeyHandle>>
fn idmap_mut(&mut self) -> Option<&mut IdMap<DataKeyHandle>>
source§fn owns(&self, item: &DataKey) -> Option<bool>
fn owns(&self, item: &DataKey) -> Option<bool>
fn store_typeinfo() -> &'static str
source§fn inserted(&mut self, handle: DataKeyHandle) -> Result<(), StamError>
fn inserted(&mut self, handle: DataKeyHandle) -> Result<(), StamError>
source§fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
source§fn preinsert(&self, item: &mut T) -> Result<(), StamError>
fn preinsert(&self, item: &mut T) -> Result<(), StamError>
fn add(self, item: T) -> Result<Self, StamError>where Self: Sized,
source§unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
source§fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>
fn get<'a, 'b>(&'a self, item: &Item<'b, T>) -> Result<&'a T, StamError>
source§fn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>
fn get_mut<'a, 'b>(&mut self, item: &Item<'b, T>) -> Result<&mut T, StamError>
source§fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
source§fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
source§fn iter<'a>(&'a self) -> StoreIter<'a, T> ⓘwhere
T: Storable<StoreType = Self>,
fn iter<'a>(&'a self) -> StoreIter<'a, T> ⓘwhere T: Storable<StoreType = Self>,
source§fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
source§fn next_handle(&self) -> T::HandleType
fn next_handle(&self) -> T::HandleType
source§fn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
source§fn bind(&mut self, item: T) -> Result<T, StamError>
fn bind(&mut self, item: T) -> Result<T, StamError>
source§fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where
T: Storable<StoreType = Self>,
fn wrap<'a>(&'a self, item: &'a T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,
source§fn wrap_owned<'a>(&'a self, item: T) -> Result<WrappedItem<'_, T>, StamError>where
T: Storable<StoreType = Self>,
fn wrap_owned<'a>(&'a self, item: T) -> Result<WrappedItem<'_, T>, StamError>where T: Storable<StoreType = Self>,
source§fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where
Self: Sized,
fn wrap_store<'a>(&'a self) -> WrappedStore<'_, T, Self>where Self: Sized,
source§impl ToCsv for AnnotationDataSet
impl ToCsv for AnnotationDataSet
source§fn to_csv_writer<W>(&self, writer: W, _table: CsvTable) -> Result<(), StamError>where
W: Write,
fn to_csv_writer<W>(&self, writer: W, _table: CsvTable) -> Result<(), StamError>where W: Write,
Writes CSV output, for the specified table, to the writer
source§fn to_csv_file(
&self,
filename: &str,
config: &Config,
table: CsvTable
) -> Result<(), StamError>
fn to_csv_file( &self, filename: &str, config: &Config, table: CsvTable ) -> Result<(), StamError>
config, the default is STAM JSON.
Note: This only writes a single table! Just use [AnnotationStore.save()] to write everything.