Enum stam::Item

source ·
pub enum Item<'a, T>where
    T: Storable,{
    Id(String),
    IdRef(&'a str),
    Ref(&'a T),
    Handle(T::HandleType),
    None,
}
Expand description

Item offers various ways of referring to a data structure of type T in the core STAM model It abstracts over public IDs (both owned an and borrowed), handles, and references.

Variants§

§

Id(String)

§

IdRef(&'a str)

§

Ref(&'a T)

§

Handle(T::HandleType)

§

None

Implementations§

source§

impl<'a, T> Item<'a, T>where T: Storable,

source

pub fn is_handle(&self) -> bool

source

pub fn is_id(&self) -> bool

source

pub fn is_none(&self) -> bool

source

pub fn is_some(&self) -> bool

source

pub fn error(&self, contextmsg: &'static str) -> StamError

source

pub fn to_string(self) -> Option<String>

Returns the ID as a new string, returns None if only handle is contained

source

pub fn as_str(&'a self) -> Option<&'a str>

Returns the ID as str, returns None if only handle is contained

source§

impl<'a, T> Item<'a, T>where T: Storable,

source

pub fn to_handle<S>(&self, store: &S) -> Option<T::HandleType>where S: StoreFor<T>,

source

pub fn to_id<S>(&'a self, store: &'a S) -> Option<&'a str>where S: StoreFor<T>,

source

pub fn to_ref<'s, S>(&'a self, store: &'s S) -> Option<&'s T>where S: StoreFor<T>,

Trait Implementations§

source§

impl<'a, T> Clone for Item<'a, T>where T: Storable,

source§

fn clone(&self) -> Self

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<'a, T> Debug for Item<'a, T>where T: Storable + Debug, T::HandleType: Debug,

source§

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

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

impl<'a, T> Default for Item<'a, T>where T: Storable,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de: 'a, 'a, T> Deserialize<'de> for Item<'a, T>where T: Storable,

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<'a, T> From<&'a String> for Item<'a, T>where T: Storable,

source§

fn from(id: &'a String) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<&'a T> for Item<'a, T>where T: Storable,

source§

fn from(instance: &'a T) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<&'a str> for Item<'a, T>where T: Storable,

source§

fn from(id: &'a str) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&AnnotationDataHandle> for Item<'a, AnnotationData>

source§

fn from(handle: &AnnotationDataHandle) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&AnnotationDataSetHandle> for Item<'a, AnnotationDataSet>

source§

fn from(handle: &AnnotationDataSetHandle) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&AnnotationHandle> for Item<'a, Annotation>

source§

fn from(handle: &AnnotationHandle) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&DataKeyHandle> for Item<'a, DataKey>

source§

fn from(handle: &DataKeyHandle) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&TextResourceHandle> for Item<'a, TextResource>

source§

fn from(handle: &TextResourceHandle) -> Self

Converts to this type from the input type.
source§

impl<'a> From<AnnotationDataHandle> for Item<'a, AnnotationData>

source§

fn from(handle: AnnotationDataHandle) -> Self

Converts to this type from the input type.
source§

impl<'a> From<AnnotationDataSetHandle> for Item<'a, AnnotationDataSet>

source§

fn from(handle: AnnotationDataSetHandle) -> Self

Converts to this type from the input type.
source§

impl<'a> From<AnnotationHandle> for Item<'a, Annotation>

source§

fn from(handle: AnnotationHandle) -> Self

Converts to this type from the input type.
source§

impl<'a> From<DataKeyHandle> for Item<'a, DataKey>

source§

fn from(handle: DataKeyHandle) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<Option<&'a str>> for Item<'a, T>where T: Storable,

source§

fn from(id: Option<&'a str>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<&AnnotationDataHandle>> for Item<'a, AnnotationData>

source§

fn from(handle: Option<&AnnotationDataHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<&AnnotationDataSetHandle>> for Item<'a, AnnotationDataSet>

source§

fn from(handle: Option<&AnnotationDataSetHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<&AnnotationHandle>> for Item<'a, Annotation>

source§

fn from(handle: Option<&AnnotationHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<&DataKeyHandle>> for Item<'a, DataKey>

source§

fn from(handle: Option<&DataKeyHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<&TextResourceHandle>> for Item<'a, TextResource>

source§

fn from(handle: Option<&TextResourceHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<&TextSelectionHandle>> for Item<'a, TextSelection>

source§

fn from(handle: Option<&TextSelectionHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<AnnotationDataHandle>> for Item<'a, AnnotationData>

source§

fn from(handle: Option<AnnotationDataHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<AnnotationDataSetHandle>> for Item<'a, AnnotationDataSet>

source§

fn from(handle: Option<AnnotationDataSetHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<AnnotationHandle>> for Item<'a, Annotation>

source§

fn from(handle: Option<AnnotationHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<DataKeyHandle>> for Item<'a, DataKey>

source§

fn from(handle: Option<DataKeyHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<Option<String>> for Item<'a, T>where T: Storable,

source§

fn from(id: Option<String>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<TextResourceHandle>> for Item<'a, TextResource>

source§

fn from(handle: Option<TextResourceHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Option<TextSelectionHandle>> for Item<'a, TextSelection>

source§

fn from(handle: Option<TextSelectionHandle>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<Option<usize>> for Item<'a, T>where T: Storable,

source§

fn from(handle: Option<usize>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<String> for Item<'a, T>where T: Storable,

source§

fn from(id: String) -> Self

Converts to this type from the input type.
source§

impl<'a> From<TextResourceHandle> for Item<'a, TextResource>

source§

fn from(handle: TextResourceHandle) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<usize> for Item<'a, T>where T: Storable,

source§

fn from(handle: usize) -> Self

Converts to this type from the input type.
source§

impl<'a, T> PartialEq<&str> for Item<'a, T>where T: Storable,

This allows us to pass a reference to any stored item and get back the best AnyId for it Will panic on totally unbounded that also don’t have a public ID

source§

fn eq(&self, other: &&str) -> 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<'a, T> PartialEq<Item<'a, T>> for Item<'a, T>where T: Storable,

source§

fn eq(&self, other: &Self) -> 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<'a, T> PartialEq<String> for Item<'a, T>where T: Storable,

source§

fn eq(&self, other: &String) -> 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<'a, T> PartialEq<str> for Item<'a, T>where T: Storable,

source§

fn eq(&self, other: &str) -> 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.

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for Item<'a, T>where T: RefUnwindSafe, <T as Storable>::HandleType: RefUnwindSafe,

§

impl<'a, T> Send for Item<'a, T>where T: Sync, <T as Storable>::HandleType: Send,

§

impl<'a, T> Sync for Item<'a, T>where T: Sync, <T as Storable>::HandleType: Sync,

§

impl<'a, T> Unpin for Item<'a, T>where <T as Storable>::HandleType: Unpin,

§

impl<'a, T> UnwindSafe for Item<'a, T>where T: RefUnwindSafe, <T as Storable>::HandleType: UnwindSafe,

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

source§

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