Skip to main content

Key

Enum Key 

Source
pub enum Key {
    Bool(bool),
    Int(i64),
    Uint(u64),
    BigInt(BigInt),
    Str(String),
    Inst(DateTime<Utc>),
    Dur(TimeDelta),
    UUID([u8; 16]),
}
Expand description

a type used as Value::Map key.

Key is a subset of Value for types that can be used a keys for Value::Map.

it supports all the api supported by its underlaying variants, and can be converted from and into Value.

§example

let map = Value::Map(HashMap::new())
	.insert(Key::from("some_key"), Value::Uint(1)); // => {"some_key": 1}

Variants§

§

Bool(bool)

boolean value, types: bool.

§

Int(i64)

signed integer value, types: i8, i16, i32, i64 vint.

§

Uint(u64)

unsigned integer value, types: u8, u16, u32, u64 vuint.

§

BigInt(BigInt)

big integer value, types: bint.

§

Str(String)

string value, types: str.

§

Inst(DateTime<Utc>)

instance value, types: inst, instN.

§

Dur(TimeDelta)

duration value, types: dur.

§

UUID([u8; 16])

uuid value, types: uuid.

Implementations§

Source§

impl Key

Source

pub fn enum_variant_key() -> &'static Key

the enum variant key in an enum map

Source

pub fn has_meta_key() -> &'static Key

the has metadata key in a metadata wrapped type

Source

pub fn inner_key() -> &'static Key

the inner value key of a metadata wrapped type

Source§

impl Key

is_T() -> bool: whether the inner value is of type T.

Source

pub fn is_bool(&self) -> bool

Source

pub fn is_uint(&self) -> bool

Source

pub fn is_int(&self) -> bool

Source

pub fn is_str(&self) -> bool

Source

pub fn is_bigint(&self) -> bool

Source

pub fn is_inst(&self) -> bool

Source

pub fn is_dur(&self) -> bool

Source

pub fn is_uuid(&self) -> bool

Source§

impl Key

Source

pub fn cast<T>(self) -> Option<T>
where Key: TryInto<T>,

cast key into T

Source§

impl Key

as_T() -> Option<T>: get copy / reference of the inner value if it is of type T, else None.

Source

pub fn as_bool(&self) -> Option<bool>

Source

pub fn as_int(&self) -> Option<i64>

Source

pub fn as_uuid(&self) -> Option<[u8; 16]>

Source

pub fn as_dur(&self) -> Option<TimeDelta>

Source

pub fn as_inst(&self) -> Option<DateTime<Utc>>

Source

pub fn as_uint(&self) -> Option<u64>

Source

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

Source

pub fn as_bigint(&self) -> Option<&BigInt>

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

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 Debug for Key

Source§

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

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

impl Default for Key

Source§

fn default() -> Self

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

impl Display for Key

Source§

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

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

impl From<&str> for Key

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 16]> for Key

Source§

fn from(v: [u8; 16]) -> Self

Converts to this type from the input type.
Source§

impl From<BigInt> for Key

Source§

fn from(v: BigInt) -> Self

Converts to this type from the input type.
Source§

impl From<DateTime<Utc>> for Key

Source§

fn from(v: DateTime<Utc>) -> Self

Converts to this type from the input type.
Source§

impl From<Key> for Value

Source§

fn from(key: Key) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Key

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<TimeDelta> for Key

Source§

fn from(v: TimeDelta) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Key

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Key

Source§

fn from(v: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Key

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Key

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Key

Source§

fn from(v: i8) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for Key

Source§

fn from(v: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Key

Source§

fn from(v: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Key

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Key

Source§

fn from(v: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Key

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Key

Source§

fn from(v: usize) -> Self

Converts to this type from the input type.
Source§

impl Hash for Key

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Index<&Key> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, index: &Key) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<&Key> for Value

Source§

fn index_mut(&mut self, index: &Key) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl PartialEq<&str> for Key

Source§

fn eq(&self, other: &&str) -> 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 PartialEq<[u8; 16]> for Key

Source§

fn eq(&self, other: &[u8; 16]) -> 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 PartialEq<BigInt> for Key

Source§

fn eq(&self, other: &BigInt) -> 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 PartialEq<DateTime<Utc>> for Key

Source§

fn eq(&self, other: &DateTime<Utc>) -> 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 PartialEq<Key> for Value

Source§

fn eq(&self, other: &Key) -> 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 PartialEq<String> for Key

Source§

fn eq(&self, other: &String) -> 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 PartialEq<TimeDelta> for Key

Source§

fn eq(&self, other: &TimeDelta) -> 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 PartialEq<bool> for Key

Source§

fn eq(&self, other: &bool) -> 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 PartialEq<i16> for &Key

Source§

fn eq(&self, other: &i16) -> 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 PartialEq<i16> for Key

Source§

fn eq(&self, other: &i16) -> 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 PartialEq<i32> for &Key

Source§

fn eq(&self, other: &i32) -> 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 PartialEq<i32> for Key

Source§

fn eq(&self, other: &i32) -> 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 PartialEq<i64> for &Key

Source§

fn eq(&self, other: &i64) -> 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 PartialEq<i64> for Key

Source§

fn eq(&self, other: &i64) -> 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 PartialEq<i8> for &Key

Source§

fn eq(&self, other: &i8) -> 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 PartialEq<i8> for Key

Source§

fn eq(&self, other: &i8) -> 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 PartialEq<isize> for &Key

Source§

fn eq(&self, other: &isize) -> 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 PartialEq<isize> for Key

Source§

fn eq(&self, other: &isize) -> 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 PartialEq<u16> for &Key

Source§

fn eq(&self, other: &u16) -> 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 PartialEq<u16> for Key

Source§

fn eq(&self, other: &u16) -> 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 PartialEq<u32> for &Key

Source§

fn eq(&self, other: &u32) -> 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 PartialEq<u32> for Key

Source§

fn eq(&self, other: &u32) -> 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 PartialEq<u64> for &Key

Source§

fn eq(&self, other: &u64) -> 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 PartialEq<u64> for Key

Source§

fn eq(&self, other: &u64) -> 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 PartialEq<u8> for &Key

Source§

fn eq(&self, other: &u8) -> 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 PartialEq<u8> for Key

Source§

fn eq(&self, other: &u8) -> 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 PartialEq<usize> for &Key

Source§

fn eq(&self, other: &usize) -> 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 PartialEq<usize> for Key

Source§

fn eq(&self, other: &usize) -> 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 PartialEq for Key

Source§

fn eq(&self, other: &Key) -> 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 TryFrom<Value> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryInto<[u8; 16]> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<[u8; 16], Self::Error>

Performs the conversion.
Source§

impl TryInto<BigInt> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<BigInt, Self::Error>

Performs the conversion.
Source§

impl TryInto<DateTime<Utc>> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<DateTime<Utc>, Self::Error>

Performs the conversion.
Source§

impl TryInto<String> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<String, Self::Error>

Performs the conversion.
Source§

impl TryInto<TimeDelta> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<TimeDelta, Self::Error>

Performs the conversion.
Source§

impl TryInto<bool> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<bool, Self::Error>

Performs the conversion.
Source§

impl TryInto<i16> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<i16, Self::Error>

Performs the conversion.
Source§

impl TryInto<i32> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<i32, Self::Error>

Performs the conversion.
Source§

impl TryInto<i64> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<i64, Self::Error>

Performs the conversion.
Source§

impl TryInto<i8> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<i8, Self::Error>

Performs the conversion.
Source§

impl TryInto<isize> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<isize, Self::Error>

Performs the conversion.
Source§

impl TryInto<u16> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<u16, Self::Error>

Performs the conversion.
Source§

impl TryInto<u32> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<u32, Self::Error>

Performs the conversion.
Source§

impl TryInto<u64> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<u64, Self::Error>

Performs the conversion.
Source§

impl TryInto<u8> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<u8, Self::Error>

Performs the conversion.
Source§

impl TryInto<usize> for Key

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<usize, Self::Error>

Performs the conversion.
Source§

impl Eq for Key

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnsafeUnpin for Key

§

impl UnwindSafe for Key

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