Enum liquid_core::model::Value

source ·
pub enum Value {
    Scalar(Scalar),
    Array(Array),
    Object(Object),
    State(State),
    Nil,
}
Expand description

An enum to represent different value types

Variants§

§

Scalar(Scalar)

A scalar value.

§

Array(Array)

A sequence of Values.

§

Object(Object)

A sequence of key/Value pairs.

§

State(State)

Query symbol.

§

Nil

Nothing.

Implementations§

source§

impl Value

source

pub fn scalar<T: Into<Scalar>>(value: T) -> Self

Create as a Scalar.

source

pub fn array<I: IntoIterator<Item = Value>>(iter: I) -> Value

Create as an Array.

source

pub fn as_view(&self) -> &dyn ValueView

Performs the conversion.

source

pub fn into_scalar(self) -> Option<Scalar>

Extracts the scalar value if it is a scalar.

source

pub fn into_array(self) -> Option<Array>

Extracts the array value if it is an array.

source

pub fn as_array_mut(&mut self) -> Option<&mut Array>

Extracts the array value as mutable if it is a object.

source

pub fn into_object(self) -> Option<Object>

Extracts the object value if it is a object.

source

pub fn as_object_mut(&mut self) -> Option<&mut Object>

Extracts the object value as mutable if it is a object.

source

pub fn into_state(self) -> Option<State>

Extracts the state if it is one

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

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

source§

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

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

impl Default for Value

source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Value

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<'s> From<&'s Value> for ValueCow<'s>

source§

fn from(other: &'s Value) -> Self

Converts to this type from the input type.
source§

impl From<Object> for Value

source§

fn from(other: Object) -> Self

Converts to this type from the input type.
source§

impl From<ScalarCow<'static>> for Value

source§

fn from(other: Scalar) -> Self

Converts to this type from the input type.
source§

impl From<State> for Value

source§

fn from(other: State) -> Self

Converts to this type from the input type.
source§

impl From<Value> for ValueCow<'static>

source§

fn from(other: Value) -> Self

Converts to this type from the input type.
source§

impl From<Vec<Value, Global>> for Value

source§

fn from(other: Array) -> Self

Converts to this type from the input type.
source§

impl<'s> PartialEq<&'s str> for Value

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 PartialEq<Date> for Value

source§

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

source§

fn eq(&self, other: &DateTime) -> 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 PartialEq<KStringBase<Box<str, Global>>> for Value

source§

fn eq(&self, other: &KString) -> 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<'s> PartialEq<KStringCowBase<'s, Box<str, Global>>> for Value

source§

fn eq(&self, other: &KStringCow<'s>) -> 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<'s> PartialEq<KStringRef<'s>> for Value

source§

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

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 PartialEq<Value> for Value

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<'v> PartialEq<Value> for ValueCow<'v>

source§

fn eq(&self, other: &Value) -> 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<'v> PartialEq<ValueViewCmp<'v>> for Value

source§

fn eq(&self, other: &ValueViewCmp<'v>) -> 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 PartialEq<bool> for Value

source§

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

source§

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

source§

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

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 PartialOrd<Value> for Value

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Value

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 ValueView for Value

source§

fn as_debug(&self) -> &dyn Debug

Get a Debug representation
source§

fn render(&self) -> DisplayCow<'_>

A Display for a BoxedValue rendered for the user.
source§

fn source(&self) -> DisplayCow<'_>

A Display for a Value as source code.
source§

fn type_name(&self) -> &'static str

Report the data type (generally for error reporting).
source§

fn query_state(&self, state: State) -> bool

Query the value’s state
source§

fn to_kstr(&self) -> KStringCow<'_>

Interpret as a string.
source§

fn to_value(&self) -> Value

Convert to an owned type.
source§

fn as_scalar(&self) -> Option<ScalarCow<'_>>

Extracts the scalar value if it is a scalar.
source§

fn as_array(&self) -> Option<&dyn ArrayView>

Extracts the array value if it is an array.
source§

fn as_object(&self) -> Option<&dyn ObjectView>

Extracts the object value if it is a object.
source§

fn as_state(&self) -> Option<State>

Extracts the state if it is one
source§

fn is_nil(&self) -> bool

Tests whether this value is nil Read more
source§

fn is_scalar(&self) -> bool

Tests whether this value is a scalar
source§

fn is_array(&self) -> bool

Tests whether this value is an array
source§

fn is_object(&self) -> bool

Tests whether this value is an object
source§

fn is_state(&self) -> bool

Tests whether this value is state
source§

impl Eq for Value

Auto Trait Implementations§

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

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

impl<T> Any for Twhere T: Any,

source§

impl<T> CloneAny for Twhere T: Any + Clone,

source§

impl<T> CloneAnySend for Twhere T: Any + Send + Clone,

source§

impl<T> CloneAnySendSync for Twhere T: Any + Send + Sync + Clone,

source§

impl<T> CloneAnySync for Twhere T: Any + Sync + Clone,

source§

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