Enum juniper::Value[][src]

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

impl<S: ScalarValue> Value<S>[src]

pub fn null() -> Self[src]

Construct a null value.

pub fn int(i: i32) -> Self[src]

👎 Deprecated since 0.11.0:

Use Value::scalar instead

Construct an integer value.

pub fn float(f: f64) -> Self[src]

👎 Deprecated since 0.11.0:

Use Value::scalar instead

Construct a floating point value.

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

👎 Deprecated since 0.11.0:

Use Value::scalar instead

Construct a string value.

pub fn boolean(b: bool) -> Self[src]

👎 Deprecated since 0.11.0:

Use Value::scalar instead

Construct a boolean value.

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

Construct a list value.

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

Construct an object value.

pub fn scalar<T>(s: T) -> Self where
    T: Into<S>, 
[src]

Construct a scalar value

pub fn is_null(&self) -> bool[src]

Does this value represent null?

pub fn as_scalar_value<'a, T>(&'a self) -> Option<&'a T> where
    &'a S: Into<Option<&'a T>>, 
[src]

View the underlying scalar value if present

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

View the underlying float value, if present.

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

View the underlying object value, if present.

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

Convert this value into an Object.

Returns None if value is not an Object.

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

Mutable view into the underlying object value, if present.

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

View the underlying list value, if present.

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

View the underlying scalar value, if present

pub fn as_string_value<'a>(&'a self) -> Option<&'a str> where
    Option<&'a String>: From<&'a S>, 
[src]

View the underlying string value, if present.

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

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

Trait Implementations

impl<S: Clone> Clone for Value<S>[src]

fn clone(&self) -> Value<S>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<S: Debug> Debug for Value<S>[src]

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

Formats the value using the given formatter. Read more

impl<S: ScalarValue> Display for Value<S>[src]

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

Formats the value using the given formatter. Read more

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

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

Performs the conversion.

impl<S> From<Object<S>> for Value<S>[src]

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

Performs the conversion.

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

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

Performs the conversion.

impl<S> From<String> for Value<S> where
    S: ScalarValue
[src]

fn from(s: String) -> Self[src]

Performs the conversion.

impl<S> From<bool> for Value<S> where
    S: ScalarValue
[src]

fn from(b: bool) -> Self[src]

Performs the conversion.

impl<S> From<f64> for Value<S> where
    S: ScalarValue
[src]

fn from(f: f64) -> Self[src]

Performs the conversion.

impl<S> From<i32> for Value<S> where
    S: ScalarValue
[src]

fn from(i: i32) -> Self[src]

Performs the conversion.

impl<S: PartialEq> PartialEq<Value<S>> for Value<S>[src]

fn eq(&self, other: &Value<S>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Value<S>) -> bool[src]

This method tests for !=.

impl<T> Serialize for Value<T> where
    T: Serialize
[src]

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl<S: ScalarValue> ToInputValue<S> for Value<S>[src]

fn to_input_value(&self) -> InputValue<S>[src]

Performs the conversion.

impl<S> StructuralPartialEq for Value<S>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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

Performs the conversion.

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

pub fn vzip(self) -> V