Trait mysql_common::value::convert::FromValue

source ·
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§

Provided Methods§

source

fn from_value(v: Value) -> Self

Will panic if could not convert v to Self.

source

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

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

source

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§

source§

impl FromValue for Value

source§

impl FromValue for Cow<'static, str>

source§

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

§

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

source§

impl FromValue for bool

source§

impl FromValue for f32

source§

impl FromValue for f64

source§

impl FromValue for i8

source§

impl FromValue for i16

source§

impl FromValue for i32

source§

impl FromValue for i64

source§

impl FromValue for i128

source§

impl FromValue for isize

source§

impl FromValue for u8

source§

impl FromValue for u16

source§

impl FromValue for u32

source§

impl FromValue for u64

source§

impl FromValue for u128

source§

impl FromValue for usize

source§

impl FromValue for NaiveDate

source§

impl FromValue for NaiveDateTime

source§

impl FromValue for NaiveTime

source§

impl FromValue for BigInt

source§

impl FromValue for BigUint

source§

impl FromValue for Uuid

source§

impl FromValue for Box<str>

source§

impl FromValue for Box<[u8]>

source§

impl FromValue for Rc<str>

source§

impl FromValue for Rc<[u8]>

§

type Intermediate = Rc<[u8]>

source§

impl FromValue for String

source§

impl FromValue for Arc<str>

source§

impl FromValue for Arc<[u8]>

source§

impl FromValue for Vec<u8>

source§

impl FromValue for Duration

source§

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

source§

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

§

type Intermediate = [u8; N]

Implementors§