[][src]Enum entity::Value

pub enum Value {
    List(Vec<Value>),
    Map(HashMap<String, Value>),
    Optional(Option<Box<Value>>),
    Primitive(PrimitiveValue),
    Text(String),
}

Represents either a primitive or complex value

Variants

List(Vec<Value>)
Optional(Option<Box<Value>>)
Primitive(PrimitiveValue)
Text(String)

Implementations

impl Value[src]

pub fn is_type(&self, r#type: ValueType) -> bool[src]

Returns true if this value is of the specified type

pub fn to_type(&self) -> ValueType[src]

Returns the type of this value

pub fn has_same_type(&self, other: &Value) -> bool[src]

Returns true if this value and the other value are of the same type

pub fn is_complex(&self) -> bool[src]

Returns true if not representing a primitive value

pub fn is_primitive(&self) -> bool[src]

Returns true if representing a primitive value

pub fn to_primitive(&self) -> Option<PrimitiveValue>[src]

Converts into underlying primitive value if representing one

pub fn to_primitive_type(&self) -> Option<PrimitiveValueType>[src]

Converts into underlying primitive type if representing one

pub fn try_into_option<T: TryFrom<Value, Error = &'static str>>(
    self
) -> Result<Option<T>, &'static str>
[src]

Attempts to convert the value to an underlying option type, succeeding if Value is the Optional variant and the inner value can be converted to the specified type.

This is only needed due to a blanket impl in the standard library blocking the ability to implement TryFrom<Value> for Option<T>, which will be available some day once specialization is implemented:

https://github.com/rust-lang/rust/issues/31844

Trait Implementations

impl Clone for Value[src]

impl Debug for Value[src]

impl Eq for Value[src]

impl<'a> From<&'a Value> for ValueType[src]

pub fn from(v: &'a Value) -> Self[src]

Produces the type of the referenced value by recursively iterating through complex types, assuming that the first value in types like list represent the entire set, defaulting to a primitive unit if a complex value does not have any items

impl<'a> From<&'a str> for Value[src]

pub fn from(s: &'a str) -> Self[src]

Converts a str slice into a value by allocating a new string

impl<T: Into<Value>> From<BTreeMap<String, T>> for Value[src]

pub fn from(map: BTreeMap<String, T>) -> Self[src]

Converts a btree map of string keys and some value into a value map

impl<T: Into<Value>> From<BTreeSet<T>> for Value[src]

pub fn from(list: BTreeSet<T>) -> Self[src]

Converts a btree set of some value into a value list

impl<T: Into<Value>> From<BinaryHeap<T>> for Value[src]

pub fn from(list: BinaryHeap<T>) -> Self[src]

Converts a binary heap of some value into a value list

impl<T: Into<Value>> From<HashMap<String, T, RandomState>> for Value[src]

pub fn from(map: HashMap<String, T>) -> Self[src]

Converts a hashmap of string keys and some value into a value map

impl<T: Into<Value>> From<HashSet<T, RandomState>> for Value[src]

pub fn from(list: HashSet<T>) -> Self[src]

Converts a hashset of some value into a value list

impl<T: Into<Value>> From<LinkedList<T>> for Value[src]

pub fn from(list: LinkedList<T>) -> Self[src]

Converts a linked list of some value into a value list

impl<T: Into<Value>> From<Option<T>> for Value[src]

pub fn from(maybe: Option<T>) -> Self[src]

Converts an option of some value into an optional value

impl From<PrimitiveValue> for Value[src]

pub fn from(v: PrimitiveValue) -> Self[src]

Converts a primitive value into a value without any allocation

impl From<String> for Value[src]

pub fn from(s: String) -> Self[src]

Converts a string into a text value without any allocation

impl From<Value> for ValueType[src]

impl<T: Into<Value>> From<Vec<T, Global>> for Value[src]

pub fn from(list: Vec<T>) -> Self[src]

Converts a vec of some value into a value list

impl<T: Into<Value>> From<VecDeque<T>> for Value[src]

pub fn from(list: VecDeque<T>) -> Self[src]

Converts a vec deque of some value into a value list

impl From<bool> for Value[src]

impl From<char> for Value[src]

impl From<f32> for Value[src]

impl From<f64> for Value[src]

impl From<i128> for Value[src]

impl From<i16> for Value[src]

impl From<i32> for Value[src]

impl From<i64> for Value[src]

impl From<i8> for Value[src]

impl From<isize> for Value[src]

impl From<u128> for Value[src]

impl From<u16> for Value[src]

impl From<u32> for Value[src]

impl From<u64> for Value[src]

impl From<u8> for Value[src]

impl From<usize> for Value[src]

impl Hash for Value[src]

impl PartialEq<Value> for Value[src]

pub fn eq(&self, other: &Self) -> bool[src]

Compares two values of same type for equality, otherwise returns false

impl PartialOrd<Value> for Value[src]

pub fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]

Compares same variants for ordering, otherwise returns none

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.