[][src]Enum juniper::Nullable

pub enum Nullable<T> {
    ImplicitNull,
    ExplicitNull,
    Some(T),
}

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

No value

ExplicitNull

No value, explicitly specified to be null

Some(T)

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]

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]

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]

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

impl<S, T> GraphQLValueAsync<S> for Nullable<T> where
    T: GraphQLValueAsync<S>,
    T::TypeInfo: Sync,
    T::Context: Sync,
    S: ScalarValue + Send + Sync
[src]

impl<T: Hash> Hash for Nullable<T>[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: PartialEq> PartialEq<Nullable<T>> for Nullable<T>[src]

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

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,