Skip to main content

DataKey

Struct DataKey 

Source
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

Source

pub fn to_json_string(&self) -> Result<String, StamError>

Writes a datakey to STAM JSON string, with appropriate formatting

Source

pub fn to_json_value(&self) -> Result<Value, StamError>

Writes a datakey to a JSON value

Source§

impl DataKey

Source

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.

Source

pub fn as_str(&self) -> &str

Returns the global id that identifies the key.

Source

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

Writes a datakey to a STAM JSON string, with appropriate formatting

Source

pub fn to_json_compact(&self) -> Result<String, StamError>

Writes a datakey to a STAM JSON string, without any indentation

Trait Implementations§

Source§

impl Clone for DataKey

Source§

fn clone(&self) -> DataKey

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl DataSize for DataKey

Source§

const IS_DYNAMIC: bool

If true, the type has a heap size that can vary at runtime, depending on the actual value.
Source§

const STATIC_HEAP_SIZE: usize

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

Estimates the size of heap memory taken up by this value. Read more
Source§

impl Debug for DataKey

Source§

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

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

impl<'bytes, Ctx> Decode<'bytes, Ctx> for DataKey

Source§

fn decode( __d777: &mut Decoder<'bytes>, __ctx777: &mut Ctx, ) -> Result<DataKey, Error>

Decode a value using the given Decoder. Read more
Source§

fn nil() -> Option<Self>

If possible, return a nil value of Self. Read more
Source§

impl<'de> Deserialize<'de> for DataKey

Source§

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 Display for DataKey

Source§

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

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

impl<Ctx> Encode<Ctx> for DataKey

Source§

fn encode<__W777>( &self, __e777: &mut Encoder<__W777>, __ctx777: &mut Ctx, ) -> Result<(), Error<__W777::Error>>
where __W777: Write,

Encode a value of this type using the given Encoder. Read more
Source§

fn is_nil(&self) -> bool

Is this value of Self a nil value? Read more
Source§

impl PartialEq for DataKey

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<DataKey> for str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for DataKey

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Request<DataKey> for DataKeyHandle

Source§

fn to_handle<'store, S>(&self, _store: &'store S) -> Option<DataKeyHandle>
where S: StoreFor<DataKey>,

Returns the handle for this item, looking it up in the store
Source§

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

If this type encapsulates an Id, this returns it (borrowed)
Source§

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>

If this type encapsulates a handle, this returns it
Source§

fn any(&self) -> bool

Represents a request for any value in certain contexts
Source§

impl<'a> Request<DataKey> for Option<DataKeyHandle>

Source§

fn to_handle<'store, S>(&self, _store: &'store S) -> Option<DataKeyHandle>
where S: StoreFor<DataKey>,

Returns the handle for this item, looking it up in the store
Source§

fn any(&self) -> bool

Represents a request for any value in certain contexts
Source§

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

If this type encapsulates an Id, this returns it (borrowed)
Source§

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>

If this type encapsulates a handle, this returns it
Source§

impl Serialize for DataKey

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Storable for DataKey

Source§

type HandleType = DataKeyHandle

Source§

type StoreHandleType = AnnotationDataSetHandle

Source§

type FullHandleType = (AnnotationDataSetHandle, DataKeyHandle)

Source§

type StoreType = AnnotationDataSet

Source§

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

Get the public identifier
Source§

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

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 with_id(self, id: impl Into<String>) -> Self

Builder pattern to set the public ID
Source§

fn carries_id() -> bool

Does this type support an ID?
Source§

fn fullhandle( storehandle: Self::StoreHandleType, handle: Self::HandleType, ) -> Self::FullHandleType

Source§

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

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>

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

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,

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>>) -> Self
where 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

Source§

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>

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

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

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.
Source§

fn store_typeinfo() -> &'static str

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 with_item(self, item: T) -> Result<Self, StamError>
where Self: Sized,

Inserts items into the store using a builder pattern.
Source§

fn has(&self, item: impl Request<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(&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>

Get a mutable reference to an item from the store by internal ID This is a low-level API method
Source§

fn remove(&mut self, item: impl Request<T>) -> Result<(), StamError>

Removes an item
Source§

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<'a>(&'a self) -> StoreIter<'a, 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<'a>(&'a mut self) -> StoreIterMut<'a, T>

Iterate over the store, mutably This is a low-level API method.
Source§

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

Return the internal id that was assigned to last inserted item This is a low-level API method.
Source§

impl TypeInfo for DataKey

Source§

fn typeinfo() -> Type

Return the type (introspection).
Source§

fn temp_id_prefix() -> &'static str

Return the prefix for temporary identifiers of this type

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V