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> Value<S>where
S: ScalarValue,
impl<S> Value<S>where
S: ScalarValue,
sourcepub fn int(i: i32) -> Self
👎Deprecated since 0.11: 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: 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: 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: 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>where
for<'a> &'a S: ScalarRefValue<'a>,
👎Deprecated since 0.11: Use Value::as_scalar_value
instead
pub fn as_float_value(&self) -> Option<f64>where
for<'a> &'a S: ScalarRefValue<'a>,
Value::as_scalar_value
insteadView 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 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.