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§
Implementations§
source§impl<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
Value::scalar
insteadConstruct an integer value.
sourcepub fn float(f: f64) -> Self
👎Deprecated since 0.11.0: Use Value::scalar
instead
pub fn float(f: f64) -> Self
Value::scalar
insteadConstruct 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
Value::scalar
insteadConstruct a string value.
sourcepub fn boolean(b: bool) -> Self
👎Deprecated since 0.11.0: Use Value::scalar
instead
pub fn boolean(b: bool) -> Self
Value::scalar
insteadConstruct 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.