pub struct DataKey { /* private fields */ }Expand description
The DataKey structure defines a vocabulary field or feature, as it is called in some
annotation paradigms. it belongs to a certain AnnotationDataSet. An
AnnotationData instance in turn makes reference to a DataKey and assigns it a value,
producing a full key/value pair.
Implementations§
source§impl DataKey
impl DataKey
sourcepub fn new(id: impl Into<String>) -> Self
pub fn new(id: impl Into<String>) -> Self
Creates a new DataKey which you can add to an AnnotationDataSet using its [StoreFor<DataKey>.add()] method.
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 DataSize for DataKey
impl DataSize for DataKey
source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
If
true, the type has a heap size that can vary at runtime, depending on the actual value.source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
The amount of space a value of the type always occupies. If
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Estimates the size of heap memory taken up by this value. Read more
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 str
impl PartialEq<DataKey> for str
source§impl PartialEq for DataKey
impl PartialEq for DataKey
source§impl<'a> Request<DataKey> for DataKeyHandle
impl<'a> Request<DataKey> for DataKeyHandle
source§fn to_handle<'store, S>(&self, _store: &'store S) -> Option<DataKeyHandle>
fn to_handle<'store, S>(&self, _store: &'store S) -> Option<DataKeyHandle>
Returns the handle for this item, looking it up in the store
source§fn requested_id(&self) -> Option<&str>
fn requested_id(&self) -> Option<&str>
If this type encapsulates an Id, this returns it (borrowed)
source§fn requested_id_owned(self) -> Option<String>
fn requested_id_owned(self) -> Option<String>
If this type encapsulates an Id, this returns it (oened)
source§fn requested_handle(&self) -> Option<T::HandleType>
fn requested_handle(&self) -> Option<T::HandleType>
If this type encapsulates a handle, this returns it
source§impl<'a> Request<DataKey> for Option<DataKeyHandle>
impl<'a> Request<DataKey> for Option<DataKeyHandle>
source§fn to_handle<'store, S>(&self, _store: &'store S) -> Option<DataKeyHandle>
fn to_handle<'store, S>(&self, _store: &'store S) -> Option<DataKeyHandle>
Returns the handle for this item, looking it up in the store
source§fn requested_id(&self) -> Option<&str>
fn requested_id(&self) -> Option<&str>
If this type encapsulates an Id, this returns it (borrowed)
source§fn requested_id_owned(self) -> Option<String>
fn requested_id_owned(self) -> Option<String>
If this type encapsulates an Id, this returns it (oened)
source§fn requested_handle(&self) -> Option<T::HandleType>
fn requested_handle(&self) -> Option<T::HandleType>
If this type encapsulates a handle, this returns it
source§impl Storable for DataKey
impl Storable for DataKey
type HandleType = DataKeyHandle
type StoreHandleType = AnnotationDataSetHandle
type FullHandleType = (AnnotationDataSetHandle, DataKeyHandle)
type StoreType = AnnotationDataSet
source§fn handle(&self) -> Option<DataKeyHandle>
fn handle(&self) -> Option<DataKeyHandle>
Retrieve the internal (numeric) id. For any type T in
StoreFor<T>, this may return None only in the initial
stage when it is still unbounded to a store, so this is almost always safe to unwrap when used in the public API.source§fn with_handle(self, intid: DataKeyHandle) -> Self
fn with_handle(self, intid: DataKeyHandle) -> Self
Set the internal ID for an item. May only be called once just after instantiation.
This is a low-level API method that can not be used publicly due to ownership restrictions.
source§fn carries_id() -> bool
fn carries_id() -> bool
Does this type support an ID?
fn fullhandle( storehandle: Self::StoreHandleType, handle: Self::HandleType ) -> Self::FullHandleType
source§fn merge(&mut self, other: Self) -> Result<(), StamError>
fn merge(&mut self, other: Self) -> Result<(), StamError>
Merge another item into this one
This is a low-level API method, mostly for internal use.
source§fn unbind(self) -> Self
fn unbind(self) -> Self
Unbind an item
This is a low-level API method that can not be used publicly due to ownership restrictions.
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 temp_id(&self) -> Result<String, StamError>
fn temp_id(&self) -> Result<String, StamError>
Generate a temporary public ID based on the internal handle.
source§fn as_resultitem<'store>(
&'store self,
store: &'store Self::StoreType,
rootstore: &'store AnnotationStore
) -> ResultItem<'store, Self>where
Self: Sized,
fn as_resultitem<'store>(
&'store self,
store: &'store Self::StoreType,
rootstore: &'store AnnotationStore
) -> ResultItem<'store, Self>where
Self: Sized,
Returns the item of type
T as a ResultItem<T>, i.e. a wrapped reference that includes a reference to
both this item as well as the store that owns it. All high-level API functions are implemented
on such Result types. You should not need to invoke this yourself.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)
This is a low-level API method that can not be used publicly due to ownership restrictions.
source§impl StoreFor<DataKey> for AnnotationDataSet
impl StoreFor<DataKey> for AnnotationDataSet
source§fn store(&self) -> &Store<DataKey>
fn store(&self) -> &Store<DataKey>
Get a reference to the entire store for the associated type
This is a low-level API method.
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
This is a low-level API method.
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
This is a low-level API method.
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
This is a low-level API method.
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>
Adds an item to the store. Returns a handle to it upon success.
source§fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
Inserts items into the store using a builder pattern
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(&self, item: impl Request<T>) -> Result<&T, StamError>
fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
Get a reference to an item from the store
This is a low-level API method, you usually want to use dedicated high-level methods like
AnnotationStore::annotation() instead.source§fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
Get a mutable reference to an item from the store by internal ID
This is a low-level API method
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.
Also works for temporary IDs if enabled.
This is a low-level API method. You usually don’t want to call this directly.
source§fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
Iterate over all items in the store
This is a low-level API method, use dedicated high-level iterators like
annotations(), resources() instead. source§fn iter_mut(&mut self) -> StoreIterMut<'_, T>
fn iter_mut(&mut self) -> StoreIterMut<'_, T>
Iterate over the store, mutably
This is a low-level API method.
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
This is a low-level API method.
source§fn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
Return the internal id that was assigned to last inserted item
This is a low-level API method.
Auto Trait Implementations§
impl Freeze for DataKey
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more