pub enum InputValue<S = DefaultScalarValue> {
Null,
Scalar(S),
Enum(String),
Variable(String),
List(Vec<Spanning<InputValue<S>>>),
Object(Vec<(Spanning<String>, Spanning<InputValue<S>>)>),
}Expand description
A JSON-like value that can be passed into the query execution, either out-of-band, or in-band as default variable values. These are not constant and might contain variables.
Lists and objects variants are spanned, i.e. they contain a reference to their position in the source file, if available.
Variants§
Null
Scalar(S)
Enum(String)
Variable(String)
List(Vec<Spanning<InputValue<S>>>)
Object(Vec<(Spanning<String>, Spanning<InputValue<S>>)>)
Implementations§
Source§impl<S> InputValue<S>
impl<S> InputValue<S>
Sourcepub fn enum_value<T: AsRef<str>>(s: T) -> Self
pub fn enum_value<T: AsRef<str>>(s: T) -> Self
Construct an enum value.
Sourcepub fn list(l: Vec<Self>) -> Self
pub fn list(l: Vec<Self>) -> Self
Construct a Spanning::unlocated list.
Convenience function to make each InputValue in the input vector
not contain any location information. Can be used from ToInputValue
implementations, where no source code position information is available.
Sourcepub fn parsed_list(l: Vec<Spanning<Self>>) -> Self
pub fn parsed_list(l: Vec<Spanning<Self>>) -> Self
Construct a located list.
Sourcepub fn object<K>(o: IndexMap<K, Self>) -> Self
pub fn object<K>(o: IndexMap<K, Self>) -> Self
Construct aa Spanning::unlocated object.
Similarly to InputValue::list it makes each key and value in the
given hash map not contain any location information.
Sourcepub fn parsed_object(o: Vec<(Spanning<String>, Spanning<Self>)>) -> Self
pub fn parsed_object(o: Vec<(Spanning<String>, Spanning<Self>)>) -> Self
Construct a located object.
Sourcepub fn into_const(self, values: &Variables<S>) -> Option<Self>where
S: Clone,
pub fn into_const(self, values: &Variables<S>) -> Option<Self>where
S: Clone,
Resolves all variables of this InputValue to their actual values.
If a variable is not present in the values:
- Returns
Nonein case this is anInputValue::Variable. - Skips field in case of an
InputValue::Objectfield. - Replaces with an
InputValue::Nullin case of anInputValue::Listelement.
This is done, because for an InputValue::Variable (or an
InputValue::Object field) a default value can be used later, if it’s
provided. While on contrary, a single InputValue::List element
cannot have a default value.
Sourcepub fn convert<T: FromInputValue<S>>(&self) -> Result<T, T::Error>
pub fn convert<T: FromInputValue<S>>(&self) -> Result<T, T::Error>
Shorthand form of invoking FromInputValue::from_input_value().
Sourcepub fn is_variable(&self) -> bool
pub fn is_variable(&self) -> bool
Does the value represent a variable?
Sourcepub fn as_enum_value(&self) -> Option<&str>
pub fn as_enum_value(&self) -> Option<&str>
View the underlying enum value, if present.
Sourcepub fn to_object_value(&self) -> Option<IndexMap<&str, &Self>>
pub fn to_object_value(&self) -> Option<IndexMap<&str, &Self>>
Converts this InputValue to a Spanning::unlocated object value.
This constructs a new IndexMap containing references to the keys
and values of self.
Sourcepub fn to_list_value(&self) -> Option<Vec<&Self>>
pub fn to_list_value(&self) -> Option<Vec<&Self>>
Converts this InputValue to a Spanning::unlocated list value.
This constructs a new Vec containing references to the values of
self.
Sourcepub fn referenced_variables(&self) -> Vec<&str>
pub fn referenced_variables(&self) -> Vec<&str>
Recursively finds all variables
Sourcepub fn unlocated_eq(&self, other: &Self) -> boolwhere
S: PartialEq,
pub fn unlocated_eq(&self, other: &Self) -> boolwhere
S: PartialEq,
Compares equality with another `InputValue`` ignoring any source position information.
Trait Implementations§
Source§impl<S: Clone> Clone for InputValue<S>
impl<S: Clone> Clone for InputValue<S>
Source§fn clone(&self) -> InputValue<S>
fn clone(&self) -> InputValue<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S: Debug> Debug for InputValue<S>
impl<S: Debug> Debug for InputValue<S>
Source§impl<'de, S: Deserialize<'de>> Deserialize<'de> for InputValue<S>
impl<'de, S: Deserialize<'de>> Deserialize<'de> for InputValue<S>
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Source§impl<S: ScalarValue> Display for InputValue<S>
impl<S: ScalarValue> Display for InputValue<S>
Source§impl<S> IntoInputValue<S> for InputValue<S>
impl<S> IntoInputValue<S> for InputValue<S>
Source§fn into_input_value(self) -> Self
fn into_input_value(self) -> Self
InputValue.Source§impl<S: PartialEq> PartialEq for InputValue<S>
impl<S: PartialEq> PartialEq for InputValue<S>
Source§impl<T: Serialize> Serialize for InputValue<T>
impl<T: Serialize> Serialize for InputValue<T>
impl<S> StructuralPartialEq for InputValue<S>
Auto Trait Implementations§
impl<S> Freeze for InputValue<S>where
S: Freeze,
impl<S> RefUnwindSafe for InputValue<S>where
S: RefUnwindSafe,
impl<S> Send for InputValue<S>where
S: Send,
impl<S> Sync for InputValue<S>where
S: Sync,
impl<S> Unpin for InputValue<S>where
S: Unpin,
impl<S> UnwindSafe for InputValue<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more