pub struct DataKey { /* private fields */ }Expand description
The DataKey class defines a vocabulary field, it
belongs to a certain AnnotationDataSet. An AnnotationData
in turn makes reference to a DataKey and assigns it a value.
Implementations§
source§impl DataKey
impl DataKey
sourcepub fn new(id: String) -> Self
pub fn new(id: String) -> Self
Creates a new DataKey which you can add to an AnnotationDataSet using AnnotationDataSet.add_key()
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the global id that identifies the key. This is a bit shorter than using get_id()
sourcepub fn annotationset(&self) -> Option<AnnotationDataSetHandle>
pub fn annotationset(&self) -> Option<AnnotationDataSetHandle>
Returns a handle to the AnnotationDataSet
sourcepub fn to_json(&self) -> Result<String, StamError>
pub fn to_json(&self) -> Result<String, StamError>
Writes a datakey to a STAM JSON string, with appropriate formatting
sourcepub fn to_json_compact(&self) -> Result<String, StamError>
pub fn to_json_compact(&self) -> Result<String, StamError>
Writes a datakey to a STAM JSON string, without any indentation
Trait Implementations§
source§impl<'de> Deserialize<'de> for DataKey
impl<'de> Deserialize<'de> for DataKey
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<DataKey> for DataKey
impl PartialEq<DataKey> for DataKey
source§impl PartialEq<DataKey> for str
impl PartialEq<DataKey> for str
source§impl Storable for DataKey
impl Storable for DataKey
type HandleType = DataKeyHandle
type StoreType = AnnotationDataSet
source§fn handle(&self) -> Option<DataKeyHandle>
fn handle(&self) -> Option<DataKeyHandle>
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, intid: DataKeyHandle)
fn set_handle(&mut self, intid: DataKeyHandle)
Set the internal ID. May only be called once (though currently not enforced).
source§fn carries_id() -> bool
fn carries_id() -> bool
Does this type support an ID?
source§fn handle_or_err(&self) -> Result<Self::HandleType, StamError>
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>
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,
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,
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 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,
Generate a random ID in a given idmap (adds it to the map and assigns it to the item)
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>
Get a reference to the entire store for the associated type
source§fn store_mut(&mut self) -> &mut Store<DataKey>
fn store_mut(&mut self) -> &mut Store<DataKey>
Get a mutable reference to the entire store for the associated type
source§fn idmap(&self) -> Option<&IdMap<DataKeyHandle>>
fn idmap(&self) -> Option<&IdMap<DataKeyHandle>>
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<DataKeyHandle>>
fn idmap_mut(&mut self) -> Option<&mut IdMap<DataKeyHandle>>
Get a mutable reference to the id map for the associated type, mapping global ids to internal ids
source§fn owns(&self, item: &DataKey) -> Option<bool>
fn owns(&self, item: &DataKey) -> Option<bool>
Tests if the item is owner by the store, returns None if ownership is unknown
fn store_typeinfo() -> &'static str
source§fn inserted(&mut self, handle: DataKeyHandle) -> Result<(), StamError>
fn inserted(&mut self, handle: DataKeyHandle) -> 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>
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>
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
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>
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>
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>
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>
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>
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>,
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> ⓘ
fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> ⓘ
Iterate over the store, mutably
source§fn next_handle(&self) -> T::HandleType
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
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>
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>,
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>,
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,
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
Auto Trait Implementations§
impl RefUnwindSafe for DataKey
impl Send for DataKey
impl Sync for DataKey
impl Unpin for DataKey
impl UnwindSafe for DataKey
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more