Enum juniper::Value

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

source§

impl<S: ScalarValue> Value<S>

source

pub fn null() -> Self

Construct a null value.

source

pub fn int(i: i32) -> Self

👎Deprecated since 0.11.0: Use Value::scalar instead

Construct an integer value.

source

pub fn float(f: f64) -> Self

👎Deprecated since 0.11.0: Use Value::scalar instead

Construct a floating point value.

source

pub fn string(s: &str) -> Self

👎Deprecated since 0.11.0: Use Value::scalar instead

Construct a string value.

source

pub fn boolean(b: bool) -> Self

👎Deprecated since 0.11.0: Use Value::scalar instead

Construct a boolean value.

source

pub fn list(l: Vec<Self>) -> Self

Construct a list value.

source

pub fn object(o: Object<S>) -> Self

Construct an object value.

source

pub fn scalar<T>(s: T) -> Selfwhere
    T: Into<S>,

Construct a scalar value

source

pub fn is_null(&self) -> bool

Does this value represent null?

source

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

source

pub fn as_float_value(&self) -> Option<f64>

View the underlying float value, if present.

source

pub fn as_object_value(&self) -> Option<&Object<S>>

View the underlying object value, if present.

source

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

Convert this value into an Object.

Returns None if value is not an Object.

source

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

Mutable view into the underlying object value, if present.

source

pub fn as_list_value(&self) -> Option<&Vec<Self>>

View the underlying list value, if present.

source

pub fn as_scalar(&self) -> Option<&S>

View the underlying scalar value, if present

source

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.

source

pub fn map_scalar_value<Into: ScalarValue>(self) -> Value<Into>

Maps the ScalarValue type of this Value into the specified one.

Trait Implementations§

source§

impl<S: Clone> Clone for Value<S>

source§

fn clone(&self) -> Value<S>

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

source§

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

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

impl<S: ScalarValue> Display for Value<S>

source§

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

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

impl<'a, S> From<&'a str> for Value<S>where
    S: ScalarValue,

source§

fn from(s: &'a str) -> Self

Converts to this type from the input type.
source§

impl<S> From<Object<S>> for Value<S>

source§

fn from(o: Object<S>) -> Self

Converts to this type from the input type.
source§

impl<S, T> From<Option<T>> for Value<S>where
    S: ScalarValue,
    Value<S>: From<T>,

source§

fn from(v: Option<T>) -> Value<S>

Converts to this type from the input type.
source§

impl<S> From<String> for Value<S>where
    S: ScalarValue,

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl<S> From<bool> for Value<S>where
    S: ScalarValue,

source§

fn from(b: bool) -> Self

Converts to this type from the input type.
source§

impl<S> From<f64> for Value<S>where
    S: ScalarValue,

source§

fn from(f: f64) -> Self

Converts to this type from the input type.
source§

impl<S> From<i32> for Value<S>where
    S: ScalarValue,

source§

fn from(i: i32) -> Self

Converts to this type from the input type.
source§

impl<S: PartialEq> PartialEq<Value<S>> for Value<S>

source§

fn eq(&self, other: &Value<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<T> Serialize for Value<T>where
    T: Serialize,

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<S: ScalarValue> ToInputValue<S> for Value<S>

source§

fn to_input_value(&self) -> InputValue<S>

Performs the conversion.
source§

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§

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · 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> ToString for Twhere
    T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
    V: MultiLane<T>,

§

fn vzip(self) -> V