pub trait FromValue: Sized {
    type Intermediate: TryFrom<Value, Error = FromValueError> + Into<Self>;

    // Provided methods
    fn from_value(v: Value) -> Self { ... }
    fn from_value_opt(v: Value) -> Result<Self, FromValueError> { ... }
    fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError> { ... }
}
Expand description

Implement this trait to convert a value to some type.

The FromRow trait requires an ability to rollback this conversion to an original Value instance. Thats the reason why there is the Intermediate type – consider implementing Into<Value> for your Intermediate type if you want FromRow to work with your type.

Required Associated Types§

type Intermediate: TryFrom<Value, Error = FromValueError> + Into<Self>

Provided Methods§

fn from_value(v: Value) -> Self

Will panic if could not convert v to Self.

fn from_value_opt(v: Value) -> Result<Self, FromValueError>

Will return Err(Error::FromValueError(v)) if could not convert v to Self.

fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>

Will return Err(Error::FromValueError(v)) if v is not convertible to Self.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl FromValue for Cow<'static, str>

§

impl FromValue for Cow<'static, [u8]>

§

type Intermediate = Cow<'static, [u8]>

§

impl FromValue for Value

§

type Intermediate = ParseIr<Value>

§

impl FromValue for bool

§

type Intermediate = ParseIrOpt<bool>

§

impl FromValue for f32

§

type Intermediate = ParseIrOpt<f32>

§

impl FromValue for f64

§

type Intermediate = ParseIrOpt<f64>

§

impl FromValue for i8

§

type Intermediate = ParseIrOpt<i8>

§

impl FromValue for i16

§

type Intermediate = ParseIrOpt<i16>

§

impl FromValue for i32

§

type Intermediate = ParseIrOpt<i32>

§

impl FromValue for i64

§

type Intermediate = ParseIrOpt<i64>

§

impl FromValue for i128

§

type Intermediate = ParseIrOpt<i128>

§

impl FromValue for isize

§

type Intermediate = ParseIrOpt<isize>

§

impl FromValue for u8

§

type Intermediate = ParseIrOpt<u8>

§

impl FromValue for u16

§

type Intermediate = ParseIrOpt<u16>

§

impl FromValue for u32

§

type Intermediate = ParseIrOpt<u32>

§

impl FromValue for u64

§

type Intermediate = ParseIrOpt<u64>

§

impl FromValue for u128

§

type Intermediate = ParseIrOpt<u128>

§

impl FromValue for usize

§

type Intermediate = ParseIrOpt<usize>

§

impl FromValue for String

§

impl FromValue for Vec<u8>

§

impl FromValue for Duration

§

type Intermediate = ParseIrOpt<Duration>

§

impl FromValue for BigInt

§

type Intermediate = ParseIr<BigInt>

§

impl FromValue for BigUint

§

type Intermediate = ParseIr<BigUint>

§

impl FromValue for Uuid

§

type Intermediate = ParseIr<Uuid>

§

impl<T> FromValue for Option<T>
where T: FromValue,

§

type Intermediate = OptionIr2<T>

§

impl<const N: usize> FromValue for [u8; N]

§

type Intermediate = [u8; N]

Implementors§

§

impl FromValue for Value

§

type Intermediate = ValueIr

§

impl<T> FromValue for Deserialized<T>

§

type Intermediate = ParseIr<Deserialized<T>>