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

ImplicitNull
Expand description

No value

ExplicitNull
Expand description

No value, explicitly specified to be null

Some(T)
Expand description

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]

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]

fn clone(&self) -> Nullable<T>[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<T: Debug> Debug for Nullable<T>[src]

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

Formats the value using the given formatter. Read more

impl<T> Default for Nullable<T>[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

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]

Performs the conversion.

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]

fn name(_: &Self::TypeInfo) -> Option<&'static str>[src]

Returns name of this GraphQLType to expose. Read more

fn meta<'r>(
    info: &Self::TypeInfo,
    registry: &mut Registry<'r, S>
) -> MetaType<'r, S> where
    S: 'r, 
[src]

Returns MetaType representing this GraphQLType.

impl<S, T> GraphQLValue<S> for Nullable<T> where
    S: ScalarValue,
    T: GraphQLValue<S>, 
[src]

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

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]

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]

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]

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]

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]

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]

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]

Resolves this GraphQLValueAsync (being an interface or an union) into a concrete downstream object type. Read more

impl<T: Hash> Hash for Nullable<T>[src]

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

Feeds this value into the given Hasher. Read more

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

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

impl<S, T> IsInputType<S> for Nullable<T> where
    T: IsInputType<S>,
    S: ScalarValue
[src]

fn mark()[src]

An arbitrary function without meaning. Read more

impl<T: Ord> Ord for Nullable<T>[src]

fn cmp(&self, other: &Nullable<T>) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<T: PartialEq> PartialEq<Nullable<T>> for Nullable<T>[src]

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

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

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

This method tests for !=.

impl<T: PartialOrd> PartialOrd<Nullable<T>> for Nullable<T>[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]

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]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater 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]

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

impl<T> Send for Nullable<T> where
    T: Send

impl<T> Sync for Nullable<T> where
    T: Sync

impl<T> Unpin for Nullable<T> where
    T: Unpin

impl<T> UnwindSafe for Nullable<T> where
    T: 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<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

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

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, 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