Enum juniper::Nullable [−][src]
pub enum Nullable<T> { ImplicitNull, ExplicitNull, Some(T), }
Expand description
Nullable
can be used in situations where you need to distinguish between an implicitly and
explicitly null input value.
The GraphQL spec states that these two field calls are similar, but are not identical:
{
field(arg: null)
field
}
The first has explicitly provided null to the argument “arg”, while the second has implicitly not provided a value to the argument “arg”. These two forms may be interpreted differently. For example, a mutation representing deleting a field vs not altering a field, respectively.
In cases where you do not need to be able to distinguish between the two types of null, you
should simply use Option<T>
.
Variants
Expand description
No value
Expand description
No value, explicitly specified to be null
Expand description
Some value T
Implementations
impl<T> Nullable<T>
[src]
impl<T> Nullable<T>
[src]pub fn is_explicit_null(&self) -> bool
[src]
pub fn is_explicit_null(&self) -> bool
[src]Returns true
if the nullable is a ExplicitNull
value.
pub fn is_implicit_null(&self) -> bool
[src]
pub fn is_implicit_null(&self) -> bool
[src]Returns true
if the nullable is a ImplicitNull
value.
pub fn as_mut(&mut self) -> Nullable<&mut T>
[src]
pub fn as_mut(&mut self) -> Nullable<&mut T>
[src]Converts from &mut Nullable<T>
to Nullable<&mut T>
.
pub fn expect(self, msg: &str) -> T
[src]
pub fn expect(self, msg: &str) -> T
[src]Returns the contained Some
value, consuming the self
value.
Panics
Panics if the value is not a Some
with a custom panic message provided by msg
.
pub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T
[src]
pub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T
[src]Returns the contained Some
value or computes it from a closure.
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Nullable<U>
[src]
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Nullable<U>
[src]Maps a Nullable<T>
to Nullable<U>
by applying a function to a contained value.
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U
[src]
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U
[src]Applies a function to the contained value (if any), or returns the provided default (if not).
pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(
self,
default: D,
f: F
) -> U
[src]
pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(
self,
default: D,
f: F
) -> U
[src]Applies a function to the contained value (if any), or computes a default (if not).
pub fn ok_or<E>(self, err: E) -> Result<T, E>
[src]
pub fn ok_or<E>(self, err: E) -> Result<T, E>
[src]Transforms the Nullable<T>
into a Result<T, E>
, mapping Some(v)
to Ok(v)
and
ImplicitNull
or ExplicitNull
to Err(err)
.
pub fn ok_or_else<E, F: FnOnce() -> E>(self, err: F) -> Result<T, E>
[src]
pub fn ok_or_else<E, F: FnOnce() -> E>(self, err: F) -> Result<T, E>
[src]Transforms the Nullable<T>
into a Result<T, E>
, mapping Some(v)
to Ok(v)
and
ImplicitNull
or ExplicitNull
to Err(err())
.
pub fn or(self, b: Self) -> Self
[src]
pub fn or(self, b: Self) -> Self
[src]Returns the nullable if it contains a value, otherwise returns b
.
pub fn or_else<F: FnOnce() -> Nullable<T>>(self, f: F) -> Nullable<T>
[src]
pub fn or_else<F: FnOnce() -> Nullable<T>>(self, f: F) -> Nullable<T>
[src]Returns the nullable if it contains a value, otherwise calls f
and
returns the result.
Trait Implementations
impl<S, T> FromInputValue<S> for Nullable<T> where
T: FromInputValue<S>,
S: ScalarValue,
[src]
impl<S, T> FromInputValue<S> for Nullable<T> where
T: FromInputValue<S>,
S: ScalarValue,
[src]fn from_input_value(v: &InputValue<S>) -> Option<Nullable<T>>
[src]
fn from_input_value(v: &InputValue<S>) -> Option<Nullable<T>>
[src]Performs the conversion.
fn from_implicit_null() -> Self
[src]
fn from_implicit_null() -> Self
[src]Performs the conversion from an absent value (e.g. to distinguish between implicit and
explicit null). The default implementation just uses from_input_value
as if an explicit
null were provided. This conversion must not fail. Read more
impl<S, T> GraphQLType<S> for Nullable<T> where
T: GraphQLType<S>,
S: ScalarValue,
[src]
impl<S, T> GraphQLType<S> for Nullable<T> where
T: GraphQLType<S>,
S: ScalarValue,
[src]impl<S, T> GraphQLValue<S> for Nullable<T> where
S: ScalarValue,
T: GraphQLValue<S>,
[src]
impl<S, T> GraphQLValue<S> for Nullable<T> where
S: ScalarValue,
T: GraphQLValue<S>,
[src]type Context = T::Context
type Context = T::Context
Context type for this GraphQLValue
. Read more
type TypeInfo = T::TypeInfo
type TypeInfo = T::TypeInfo
Type that may carry additional schema information for this GraphQLValue
. Read more
fn type_name(&self, _: &Self::TypeInfo) -> Option<&'static str>
[src]
fn type_name(&self, _: &Self::TypeInfo) -> Option<&'static str>
[src]Returns name of the GraphQLType
exposed by this GraphQLValue
. Read more
fn resolve(
&self,
info: &Self::TypeInfo,
_: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]
fn resolve(
&self,
info: &Self::TypeInfo,
_: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]Resolves the provided selection_set
against this GraphQLValue
. Read more
fn resolve_field(
&self,
_info: &Self::TypeInfo,
_field_name: &str,
_arguments: &Arguments<'_, S>,
_executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]
fn resolve_field(
&self,
_info: &Self::TypeInfo,
_field_name: &str,
_arguments: &Arguments<'_, S>,
_executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]Resolves the value of a single field on this GraphQLValue
. Read more
fn resolve_into_type(
&self,
info: &Self::TypeInfo,
type_name: &str,
selection_set: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]
fn resolve_into_type(
&self,
info: &Self::TypeInfo,
type_name: &str,
selection_set: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]Resolves this GraphQLValue
(being an interface or an union) into a concrete
downstream object type. Read more
fn concrete_type_name(
&self,
context: &Self::Context,
info: &Self::TypeInfo
) -> String
[src]
fn concrete_type_name(
&self,
context: &Self::Context,
info: &Self::TypeInfo
) -> String
[src]Returns the concrete GraphQLType
name for this GraphQLValue
being an interface,
an union or an object. Read more
impl<S, T> GraphQLValueAsync<S> for Nullable<T> where
T: GraphQLValueAsync<S>,
T::TypeInfo: Sync,
T::Context: Sync,
S: ScalarValue + Send + Sync,
[src]
impl<S, T> GraphQLValueAsync<S> for Nullable<T> where
T: GraphQLValueAsync<S>,
T::TypeInfo: Sync,
T::Context: Sync,
S: ScalarValue + Send + Sync,
[src]fn resolve_async<'a>(
&'a self,
info: &'a Self::TypeInfo,
_: Option<&'a [Selection<'_, S>]>,
executor: &'a Executor<'_, '_, Self::Context, S>
) -> BoxFuture<'a, ExecutionResult<S>>
[src]
fn resolve_async<'a>(
&'a self,
info: &'a Self::TypeInfo,
_: Option<&'a [Selection<'_, S>]>,
executor: &'a Executor<'_, '_, Self::Context, S>
) -> BoxFuture<'a, ExecutionResult<S>>
[src]Resolves the provided selection_set
against this GraphQLValueAsync
. Read more
fn resolve_field_async<'a>(
&'a self,
_info: &'a Self::TypeInfo,
_field_name: &'a str,
_arguments: &'a Arguments<'_, S>,
_executor: &'a Executor<'_, '_, Self::Context, S>
) -> BoxFuture<'a, ExecutionResult<S>>
[src]
fn resolve_field_async<'a>(
&'a self,
_info: &'a Self::TypeInfo,
_field_name: &'a str,
_arguments: &'a Arguments<'_, S>,
_executor: &'a Executor<'_, '_, Self::Context, S>
) -> BoxFuture<'a, ExecutionResult<S>>
[src]Resolves the value of a single field on this GraphQLValueAsync
. Read more
fn resolve_into_type_async<'a>(
&'a self,
info: &'a Self::TypeInfo,
type_name: &str,
selection_set: Option<&'a [Selection<'a, S>]>,
executor: &'a Executor<'a, 'a, Self::Context, S>
) -> BoxFuture<'a, ExecutionResult<S>>
[src]
fn resolve_into_type_async<'a>(
&'a self,
info: &'a Self::TypeInfo,
type_name: &str,
selection_set: Option<&'a [Selection<'a, S>]>,
executor: &'a Executor<'a, 'a, Self::Context, S>
) -> BoxFuture<'a, ExecutionResult<S>>
[src]Resolves this GraphQLValueAsync
(being an interface or an union) into a
concrete downstream object type. Read more
impl<S, T> IsInputType<S> for Nullable<T> where
T: IsInputType<S>,
S: ScalarValue,
[src]
impl<S, T> IsInputType<S> for Nullable<T> where
T: IsInputType<S>,
S: ScalarValue,
[src]impl<T: Ord> Ord for Nullable<T>
[src]
impl<T: Ord> Ord for Nullable<T>
[src]impl<T: PartialOrd> PartialOrd<Nullable<T>> for Nullable<T>
[src]
impl<T: PartialOrd> PartialOrd<Nullable<T>> for Nullable<T>
[src]fn partial_cmp(&self, other: &Nullable<T>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Nullable<T>) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<S, T> ToInputValue<S> for Nullable<T> where
T: ToInputValue<S>,
S: ScalarValue,
[src]
impl<S, T> ToInputValue<S> for Nullable<T> where
T: ToInputValue<S>,
S: ScalarValue,
[src]fn to_input_value(&self) -> InputValue<S>
[src]
fn to_input_value(&self) -> InputValue<S>
[src]Performs the conversion.
impl<T: Copy> Copy for Nullable<T>
[src]
impl<T: Eq> Eq for Nullable<T>
[src]
impl<T> StructuralEq for Nullable<T>
[src]
impl<T> StructuralPartialEq for Nullable<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Nullable<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Nullable<T> where
T: Send,
T: Send,
impl<T> Sync for Nullable<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Nullable<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Nullable<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,