pub enum Value {
    Variable(Variable),
    Int {
        value: Float,
        loc: HirNodeLocation,
    },
    Float {
        value: Float,
        loc: HirNodeLocation,
    },
    String {
        value: String,
        loc: HirNodeLocation,
    },
    Boolean {
        value: bool,
        loc: HirNodeLocation,
    },
    Null {
        loc: HirNodeLocation,
    },
    Enum {
        value: Name,
        loc: HirNodeLocation,
    },
    List {
        value: Vec<Value>,
        loc: HirNodeLocation,
    },
    Object {
        value: Vec<(Name, Value)>,
        loc: HirNodeLocation,
    },
}

Variants§

§

Variable(Variable)

§

Int

Fields

§value: Float
§

Float

Fields

§value: Float
§

String

Fields

§value: String
§

Boolean

Fields

§value: bool
§

Null

§

Enum

Fields

§value: Name
§

List

Fields

§value: Vec<Value>
§

Object

Fields

§value: Vec<(Name, Value)>

Implementations§

source§

impl Value

source

pub fn is_same_value(&self, other: &Value) -> bool

Returns true if other represents the same value as self. This is different from the Eq implementation as it ignores location information.

source

pub fn loc(&self) -> HirNodeLocation

Get current value’s location.

source

pub fn variables(&self) -> Vec<Variable>

source

pub fn kind(&self) -> &str

source

pub fn is_variable(&self) -> bool

Returns true if the value is Variable.

source

pub fn is_null(&self) -> bool

Returns true if the value is Null.

source

pub fn as_i32(&self) -> Option<i32>

Returns an i32 if the value is a number and can be represented as an i32.

source

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

Returns an f64 if the value is a number and can be represented as an f64.

source

pub fn as_str(&self) -> Option<&str>

Returns a str if the value is a string.

source

pub fn as_bool(&self) -> Option<bool>

Returns true/false if the value is a boolean.

source

pub fn as_list(&self) -> Option<&Vec<Value>>

Returns the inner list if the value is a List type.

source

pub fn as_object(&self) -> Option<&Vec<(Name, Value)>>

Returns a keys/values list if the value is an input object.

source

pub fn as_variable(&self) -> Option<&Variable>

Returns the hir::Variable if the value is a variable reference.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

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

source§

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

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

impl Hash for Value

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Value> for Value

source§

fn eq(&self, other: &Value) -> 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 TryFrom<&Value> for f64

Coerce to a Float input type (from either Float or Int syntax)

https://spec.graphql.org/draft/#sec-Float.Input-Coercion

§

type Error = FloatCoercionError

The type returned in the event of a conversion error.
source§

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&Value> for i32

§

type Error = IntCoercionError

The type returned in the event of a conversion error.
source§

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for f64

Coerce to a Float input type (from either Float or Int syntax)

https://spec.graphql.org/draft/#sec-Float.Input-Coercion

§

type Error = FloatCoercionError

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for i32

§

type Error = IntCoercionError

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Value

source§

impl StructuralEq for Value

source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
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.
source§

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

Performs the conversion.