Skip to main content

FromScalarValue

Trait FromScalarValue 

Source
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§

Source

type Error: IntoFieldError<S> + 's

Parsing error of a ScalarValue.

Required Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl<'___a, Tz, __S> FromScalarValue<'___a, __S> for DateTime<Tz>
where Tz: TimeZone + FromFixedOffset, Tz::Offset: Display, __S: ScalarValue, Self: '___a,

Available on crate feature chrono only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Tz
where __S: ScalarValue, Self: '___a,

Available on crate feature chrono-tz only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for BigDecimal
where __S: ScalarValue, Self: '___a,

Available on crate feature bigdecimal only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for DateTime
where __S: ScalarValue, Self: '___a,

Available on crate feature bson only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for ObjectId
where __S: ScalarValue, Self: '___a,

Available on crate feature bson only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for NaiveDate
where __S: ScalarValue, Self: '___a,

Available on crate feature chrono only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for NaiveDateTime
where __S: ScalarValue, Self: '___a,

Available on crate feature chrono only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for NaiveTime
where __S: ScalarValue, Self: '___a,

Available on crate feature chrono only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for CompactString
where __S: ScalarValue, Self: '___a,

Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Date
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for DateTime
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Time
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Span
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Timestamp
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Offset
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for TimeZone
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Zoned
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Decimal
where __S: ScalarValue, Self: '___a,

Available on crate feature rust_decimal only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Date
where __S: ScalarValue, Self: '___a,

Available on crate feature time only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for OffsetDateTime
where __S: ScalarValue, Self: '___a,

Available on crate feature time only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for PrimitiveDateTime
where __S: ScalarValue, Self: '___a,

Available on crate feature time only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Time
where __S: ScalarValue, Self: '___a,

Available on crate feature time only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for UtcOffset
where __S: ScalarValue, Self: '___a,

Available on crate feature time only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Url
where __S: ScalarValue, Self: '___a,

Available on crate feature url only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for Uuid
where __S: ScalarValue, Self: '___a,

Available on crate feature uuid only.
Source§

impl<'s, S> FromScalarValue<'s, S> for &'s str
where S: TryToPrimitive<'s, Self, Error: IntoFieldError<S>> + 's,

Source§

type Error = <S as TryToPrimitive<'s, &'s str>>::Error

Source§

fn from_scalar_value(v: &'s S) -> Result<Self, Self::Error>

Source§

impl<'s, S> FromScalarValue<'s, S> for bool
where S: TryToPrimitive<'s, Self, Error: IntoFieldError<S>> + 's,

Source§

impl<'s, S> FromScalarValue<'s, S> for f64
where S: TryToPrimitive<'s, Self, Error: IntoFieldError<S>> + 's,

Source§

impl<'s, S> FromScalarValue<'s, S> for i32
where S: TryToPrimitive<'s, Self, Error: IntoFieldError<S>> + 's,

Source§

impl<'s, S> FromScalarValue<'s, S> for &'s S

Source§

impl<'s, S> FromScalarValue<'s, S> for String
where S: TryToPrimitive<'s, Self, Error: IntoFieldError<S>> + 's,

Source§

impl<'s, T, S> FromScalarValue<'s, S> for Box<T>
where S: ScalarValue, T: FromScalarValue<'s, S> + 's,

Source§

type Error = <T as FromScalarValue<'s, S>>::Error

Source§

fn from_scalar_value(v: &'s S) -> Result<Self, Self::Error>

Source§

impl<'s, T, S> FromScalarValue<'s, S> for Arc<T>
where S: ScalarValue, T: FromScalarValue<'s, S> + 's,

Source§

type Error = <T as FromScalarValue<'s, S>>::Error

Source§

fn from_scalar_value(v: &'s S) -> Result<Self, Self::Error>

Implementors§

Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for juniper::integrations::jiff::TimeZone
where __S: ScalarValue, Self: '___a,

Available on crate feature jiff only.
Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for ArcStr
where __S: ScalarValue, Self: '___a,

Source§

impl<'___a, __S> FromScalarValue<'___a, __S> for ID
where __S: ScalarValue, Self: '___a,

Source§

impl<'s, S: ScalarValue> FromScalarValue<'s, S> for &'s Scalar<S>