EntityLabel

Enum EntityLabel 

Source
pub enum EntityLabel<K, T, L> {
    KeyLabel(Key<K>, L),
    Data(Box<T>),
    None,
}
Expand description

Enum for situations when you want to define not just a Key but also a Label

This may be useful for faster access to avoid an extra LEFT JOIN or because you may have missing data, thus no Key, and having the Label makes the entity still valid

Variants§

§

KeyLabel(Key<K>, L)

Key and Label for this entity

§

Data(Box<T>)

Created/Fetched data for the entity

§

None

For when you have no data to fill or null from database

Implementations§

Source§

impl<K, T, L> EntityLabel<K, T, L>

Source

pub fn data(&self) -> Result<&T, Error>

Returns the data if it exists and was fetched/created

Source

pub fn data_mut(&mut self) -> Result<&mut T, Error>

Returns the mutable data if it exists and was fetched/created

Source

pub fn is_keylabel(&self) -> bool

Is this a KeyLabel variant?

Source

pub fn is_data(&self) -> bool

Is this a Data variant?

Source

pub fn is_none(&self) -> bool

Is this a None variant?

Trait Implementations§

Source§

impl<K, T, L> Clone for EntityLabel<K, T, L>
where K: Clone, T: Clone, L: Clone,

Source§

fn clone(&self) -> EntityLabel<K, T, L>

Returns a duplicate 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<K, T, L> Debug for EntityLabel<K, T, L>
where K: Debug, T: Debug, L: Debug,

Source§

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

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

impl<K, T, L> Default for EntityLabel<K, T, L>

Source§

fn default() -> EntityLabel<K, T, L>

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

impl<'de, K, T, L> Deserialize<'de> for EntityLabel<K, T, L>
where K: Deserialize<'de>, T: Deserialize<'de>, L: Deserialize<'de>,

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<EntityLabel<K, T, L>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<K, T, L> From<T> for EntityLabel<K, T, L>

Source§

fn from(entity: T) -> EntityLabel<K, T, L>

Converts to this type from the input type.
Source§

impl<K, T, L> Keyed for EntityLabel<K, T, L>
where T: Keyed<KeyType = K>,

Source§

type KeyType = K

The type of the Key
Source§

fn key(&self) -> Result<&Key<<EntityLabel<K, T, L> as Keyed>::KeyType>, Error>

Returns the Key for the Entity
Source§

impl<K, T, L> Label for EntityLabel<K, T, L>
where T: Label<LabelType = L>,

Source§

type LabelType = L

The type of the Label
Source§

fn label(&self) -> Result<&<EntityLabel<K, T, L> as Label>::LabelType, Error>

Returns the Label for the Entity
Source§

impl<K, T, L> PartialEq for EntityLabel<K, T, L>
where K: PartialEq, T: PartialEq, L: PartialEq,

Source§

fn eq(&self, other: &EntityLabel<K, T, L>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<K, T, L> Serialize for EntityLabel<K, T, L>
where K: Serialize, T: Serialize, L: Serialize,

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

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

impl<K, T, L> Eq for EntityLabel<K, T, L>
where K: Eq, T: Eq, L: Eq,

Source§

impl<K, T, L> StructuralPartialEq for EntityLabel<K, T, L>

Auto Trait Implementations§

§

impl<K, T, L> Freeze for EntityLabel<K, T, L>
where L: Freeze, K: Freeze,

§

impl<K, T, L> RefUnwindSafe for EntityLabel<K, T, L>

§

impl<K, T, L> Send for EntityLabel<K, T, L>
where L: Send, K: Send, T: Send,

§

impl<K, T, L> Sync for EntityLabel<K, T, L>
where L: Sync, K: Sync, T: Sync,

§

impl<K, T, L> Unpin for EntityLabel<K, T, L>
where L: Unpin, K: Unpin,

§

impl<K, T, L> UnwindSafe for EntityLabel<K, T, L>
where L: UnwindSafe, K: UnwindSafe, T: UnwindSafe,

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<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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
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<K, T, L> Tagged for T
where T: Keyed<KeyType = K> + Label<LabelType = L>, K: Display, L: Display,

Source§

fn tag(&self) -> Result<Tag, Error>

Returns the Tag for the Entity
Source§

fn has_tag(&self) -> bool

The entity does not have a valid tag if it doesn’t have a Key
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, 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,