TryToPrimitive

Trait TryToPrimitive 

Source
pub trait TryToPrimitive<'me, T: 'me> {
    type Error: 'me;

    // Required method
    fn try_to_primitive(&'me self) -> Result<T, Self::Error>;
}
Expand description

Fallible representation of a ScalarValue as one of the types it consists of, or derived ones from them.

§Implementation

Implementing this trait for a type allows to specify this type directly in the from_input() function when implementing a GraphQLScalar via derive macro.

#[derive(ScalarValue)] automatically implements this trait for all the required primitive types if #[to_<type>] and #[as_<type>] attributes are specified.

Required Associated Types§

Source

type Error: 'me

Error if this ScalarValue doesn’t represent the expected type.

Required Methods§

Source

fn try_to_primitive(&'me self) -> Result<T, Self::Error>

Tries to represent this ScalarValue as the expected type.

§Errors

If this ScalarValue doesn’t represent the expected type.

Implementors§