pub enum Value<S = DefaultScalarValue> {
Null,
Scalar(S),
List(Vec<Value<S>>),
Object(Object<S>),
}
Expand description
Serializable value returned from query and field execution.
Used by the execution engine and resolvers to build up the response
structure. Similar to the Json
type found in the serialize crate.
It is also similar to the InputValue
type, but can not contain enum
values or variables. Also, lists and objects do not contain any location
information since they are generated by resolving fields and values rather
than parsing a source query.
Variants
Null
Scalar(S)
List(Vec<Value<S>>)
Object(Object<S>)
Implementations
sourceimpl<S: ScalarValue> Value<S>
impl<S: ScalarValue> Value<S>
sourcepub fn int(i: i32) -> Self
👎 Deprecated since 0.11.0: Use Value::scalar
instead
pub fn int(i: i32) -> Self
Use Value::scalar
instead
Construct an integer value.
sourcepub fn float(f: f64) -> Self
👎 Deprecated since 0.11.0: Use Value::scalar
instead
pub fn float(f: f64) -> Self
Use Value::scalar
instead
Construct a floating point value.
sourcepub fn string(s: &str) -> Self
👎 Deprecated since 0.11.0: Use Value::scalar
instead
pub fn string(s: &str) -> Self
Use Value::scalar
instead
Construct a string value.
sourcepub fn boolean(b: bool) -> Self
👎 Deprecated since 0.11.0: Use Value::scalar
instead
pub fn boolean(b: bool) -> Self
Use Value::scalar
instead
Construct a boolean value.
sourcepub fn as_scalar_value<'a, T>(&'a self) -> Option<&'a T> where
&'a S: Into<Option<&'a T>>,
pub fn as_scalar_value<'a, T>(&'a self) -> Option<&'a T> where
&'a S: Into<Option<&'a T>>,
View the underlying scalar value if present
sourcepub fn as_float_value(&self) -> Option<f64>
pub fn as_float_value(&self) -> Option<f64>
View the underlying float value, if present.
sourcepub fn as_object_value(&self) -> Option<&Object<S>>
pub fn as_object_value(&self) -> Option<&Object<S>>
View the underlying object value, if present.
sourcepub fn into_object(self) -> Option<Object<S>>
pub fn into_object(self) -> Option<Object<S>>
Convert this value into an Object.
Returns None if value is not an Object.
sourcepub fn as_mut_object_value(&mut self) -> Option<&mut Object<S>>
pub fn as_mut_object_value(&mut self) -> Option<&mut Object<S>>
Mutable view into the underlying object value, if present.
sourcepub fn as_list_value(&self) -> Option<&Vec<Self>>
pub fn as_list_value(&self) -> Option<&Vec<Self>>
View the underlying list value, if present.
sourcepub fn as_string_value<'a>(&'a self) -> Option<&'a str> where
Option<&'a String>: From<&'a S>,
pub fn as_string_value<'a>(&'a self) -> Option<&'a str> where
Option<&'a String>: From<&'a S>,
View the underlying string value, if present.
sourcepub fn map_scalar_value<Into: ScalarValue>(self) -> Value<Into>
pub fn map_scalar_value<Into: ScalarValue>(self) -> Value<Into>
Maps the ScalarValue
type of this Value
into the specified one.
Trait Implementations
sourceimpl<S: ScalarValue> Display for Value<S>
impl<S: ScalarValue> Display for Value<S>
sourceimpl<'a, S> From<&'a str> for Value<S> where
S: ScalarValue,
impl<'a, S> From<&'a str> for Value<S> where
S: ScalarValue,
sourceimpl<S> From<String> for Value<S> where
S: ScalarValue,
impl<S> From<String> for Value<S> where
S: ScalarValue,
sourceimpl<S> From<bool> for Value<S> where
S: ScalarValue,
impl<S> From<bool> for Value<S> where
S: ScalarValue,
sourceimpl<S> From<f64> for Value<S> where
S: ScalarValue,
impl<S> From<f64> for Value<S> where
S: ScalarValue,
sourceimpl<S> From<i32> for Value<S> where
S: ScalarValue,
impl<S> From<i32> for Value<S> where
S: ScalarValue,
sourceimpl<S: ScalarValue> ToInputValue<S> for Value<S>
impl<S: ScalarValue> ToInputValue<S> for Value<S>
sourcefn to_input_value(&self) -> InputValue<S>
fn to_input_value(&self) -> InputValue<S>
Performs the conversion.
impl<S> StructuralPartialEq for Value<S>
Auto Trait Implementations
impl<S> RefUnwindSafe for Value<S> where
S: RefUnwindSafe,
impl<S> Send for Value<S> where
S: Send,
impl<S> Sync for Value<S> where
S: Sync,
impl<S> Unpin for Value<S> where
S: Unpin,
impl<S> UnwindSafe for Value<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more