pub trait FromInputValue<S = DefaultScalarValue>: Sized {
type Error;
// Required method
fn from_input_value(v: &InputValue<S>) -> Result<Self, Self::Error>;
// Provided method
fn from_implicit_null() -> Result<Self, Self::Error> { ... }
}
Expand description
Parsing of an unstructured input value into a Rust data type.
The conversion can fail, and must in that case return Err
. Thus not
restricted in the definition of this trait, the returned Err
should be
convertible with IntoFieldError
to fit well into the library machinery.
Implemented automatically by the convenience proc macro graphql_scalar!
or by deriving GraphQLEnum
.
Must be implemented manually when manually exposing new enums or scalars.
Required Associated Types§
Sourcetype Error
type Error
Type of this conversion error.
Thus not restricted, it should be convertible with IntoFieldError
to
fit well into the library machinery.
Required Methods§
Sourcefn from_input_value(v: &InputValue<S>) -> Result<Self, Self::Error>
fn from_input_value(v: &InputValue<S>) -> Result<Self, Self::Error>
Performs the conversion.
Provided Methods§
Sourcefn from_implicit_null() -> Result<Self, Self::Error>
fn from_implicit_null() -> Result<Self, Self::Error>
Performs the conversion from an absent value (e.g. to distinguish
between implicit and explicit null
).
The default implementation just calls from_input_value()
as if an
explicit null
was provided.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.