pub trait FromScalarValue<'s, S: 's = DefaultScalarValue>: Sized {
type Error: IntoFieldError<S> + 's;
// Required method
fn from_scalar_value(v: &'s S) -> Result<Self, Self::Error>;
}Expand description
Parsing of a ScalarValue into a Rust data type.
The conversion can fail, and must in that case return an Err.
Use the ScalarValue::try_to() method as a shortcut for this conversion.
§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.
Also, #[derive(GraphQLScalar)] automatically implements this trait
for a type.
Required Associated Types§
Sourcetype Error: IntoFieldError<S> + 's
type Error: IntoFieldError<S> + 's
Parsing error of a ScalarValue.
Required Methods§
Sourcefn from_scalar_value(v: &'s S) -> Result<Self, Self::Error>
fn from_scalar_value(v: &'s S) -> Result<Self, Self::Error>
Parses the provided ScalarValue.
§Errors
If this type cannot be parsed from the provided ScalarValue.
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.