[−][src]Enum juniper::Nullable
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
No value
No value, explicitly specified to be null
Some value T
Implementations
impl<T> Nullable<T>
[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]
Returns true
if the nullable is a ImplicitNull
value.
pub fn is_some(&self) -> bool
[src]
Returns true
if the nullable is a Some
value.
pub fn is_null(&self) -> bool
[src]
Returns true
if the nullable is not a Some
value.
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]
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(self, default: T) -> T
[src]
Returns the contained Some
value or a provided default.
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]
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]
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]
self,
default: D,
f: F
) -> U
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]
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]
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]
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]
Returns the nullable if it contains a value, otherwise calls f
and
returns the result.
pub fn replace(&mut self, value: T) -> Self
[src]
Replaces the actual value in the nullable by the value given in parameter, returning the
old value if present, leaving a Some
in its place without deinitializing either one.
pub fn some(self) -> Option<T>
[src]
Converts from Nullable<T>
to Option<T>
.
pub fn explicit(self) -> Option<Option<T>>
[src]
Converts from Nullable<T>
to Option<Option<T>>
, mapping Some(v)
to Some(Some(v))
,
ExplicitNull
to Some(None)
, and ImplicitNull
to None
.
impl<T: Copy> Nullable<&T>
[src]
pub fn copied(self) -> Nullable<T>
[src]
Maps a Nullable<&T>
to a Nullable<T>
by copying the contents of the nullable.
impl<T: Copy> Nullable<&mut T>
[src]
pub fn copied(self) -> Nullable<T>
[src]
Maps a Nullable<&mut T>
to a Nullable<T>
by copying the contents of the nullable.
impl<T: Clone> Nullable<&T>
[src]
pub fn cloned(self) -> Nullable<T>
[src]
Maps a Nullable<&T>
to a Nullable<T>
by cloning the contents of the nullable.
impl<T: Clone> Nullable<&mut T>
[src]
pub fn cloned(self) -> Nullable<T>
[src]
Maps a Nullable<&mut T>
to a Nullable<T>
by cloning the contents of the nullable.
Trait Implementations
impl<T: Clone> Clone for Nullable<T>
[src]
impl<T: Copy> Copy for Nullable<T>
[src]
impl<T: Debug> Debug for Nullable<T>
[src]
impl<T> Default for Nullable<T>
[src]
impl<T: Eq> Eq for Nullable<T>
[src]
impl<S, T> FromInputValue<S> for Nullable<T> where
T: FromInputValue<S>,
S: ScalarValue,
[src]
T: FromInputValue<S>,
S: ScalarValue,
pub fn from_input_value(v: &InputValue<S>) -> Option<Nullable<T>>
[src]
pub fn from_implicit_null() -> Self
[src]
impl<S, T> GraphQLType<S> for Nullable<T> where
T: GraphQLType<S>,
S: ScalarValue,
[src]
T: GraphQLType<S>,
S: ScalarValue,
pub fn name(_: &Self::TypeInfo) -> Option<&'static str>
[src]
pub fn meta<'r>(
info: &Self::TypeInfo,
registry: &mut Registry<'r, S>
) -> MetaType<'r, S> where
S: 'r,
[src]
info: &Self::TypeInfo,
registry: &mut Registry<'r, S>
) -> MetaType<'r, S> where
S: 'r,
impl<S, T> GraphQLValue<S> for Nullable<T> where
S: ScalarValue,
T: GraphQLValue<S>,
[src]
S: ScalarValue,
T: GraphQLValue<S>,
type Context = T::Context
Context type for this GraphQLValue
. Read more
type TypeInfo = T::TypeInfo
Type that may carry additional schema information for this GraphQLValue
. Read more
pub fn type_name(&self, _: &Self::TypeInfo) -> Option<&'static str>
[src]
pub fn resolve(
&self,
info: &Self::TypeInfo,
_: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]
&self,
info: &Self::TypeInfo,
_: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
pub fn resolve_field(
&self,
_info: &Self::TypeInfo,
_field_name: &str,
_arguments: &Arguments<'_, S>,
_executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]
&self,
_info: &Self::TypeInfo,
_field_name: &str,
_arguments: &Arguments<'_, S>,
_executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
pub fn resolve_into_type(
&self,
info: &Self::TypeInfo,
type_name: &str,
selection_set: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
[src]
&self,
info: &Self::TypeInfo,
type_name: &str,
selection_set: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>
) -> ExecutionResult<S>
pub fn concrete_type_name(
&self,
context: &Self::Context,
info: &Self::TypeInfo
) -> String
[src]
&self,
context: &Self::Context,
info: &Self::TypeInfo
) -> String
impl<S, T> GraphQLValueAsync<S> for Nullable<T> where
T: GraphQLValueAsync<S>,
T::TypeInfo: Sync,
T::Context: Sync,
S: ScalarValue + Send + Sync,
[src]
T: GraphQLValueAsync<S>,
T::TypeInfo: Sync,
T::Context: Sync,
S: ScalarValue + Send + Sync,
pub 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]
&'a self,
info: &'a Self::TypeInfo,
_: Option<&'a [Selection<'_, S>]>,
executor: &'a Executor<'_, '_, Self::Context, S>
) -> BoxFuture<'a, ExecutionResult<S>>
pub 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]
&'a self,
_info: &'a Self::TypeInfo,
_field_name: &'a str,
_arguments: &'a Arguments<'_, S>,
_executor: &'a Executor<'_, '_, Self::Context, S>
) -> BoxFuture<'a, ExecutionResult<S>>
pub 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]
&'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>>
impl<T: Hash> Hash for Nullable<T>
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<S, T> IsInputType<S> for Nullable<T> where
T: IsInputType<S>,
S: ScalarValue,
[src]
T: IsInputType<S>,
S: ScalarValue,
impl<T: Ord> Ord for Nullable<T>
[src]
pub fn cmp(&self, other: &Nullable<T>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T: PartialEq> PartialEq<Nullable<T>> for Nullable<T>
[src]
pub fn eq(&self, other: &Nullable<T>) -> bool
[src]
pub fn ne(&self, other: &Nullable<T>) -> bool
[src]
impl<T: PartialOrd> PartialOrd<Nullable<T>> for Nullable<T>
[src]
pub fn partial_cmp(&self, other: &Nullable<T>) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Nullable<T>) -> bool
[src]
pub fn le(&self, other: &Nullable<T>) -> bool
[src]
pub fn gt(&self, other: &Nullable<T>) -> bool
[src]
pub fn ge(&self, other: &Nullable<T>) -> bool
[src]
impl<T> StructuralEq for Nullable<T>
[src]
impl<T> StructuralPartialEq for Nullable<T>
[src]
impl<S, T> ToInputValue<S> for Nullable<T> where
T: ToInputValue<S>,
S: ScalarValue,
[src]
T: ToInputValue<S>,
S: ScalarValue,
pub fn to_input_value(&self) -> InputValue<S>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Nullable<T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Send for Nullable<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for Nullable<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for Nullable<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Nullable<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
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]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,