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§
type Intermediate: TryFrom<Value, Error = FromValueError> + Into<Self>
Provided Methods§
sourcefn from_value(v: Value) -> Self
fn from_value(v: Value) -> Self
Will panic if could not convert v
to Self
.
sourcefn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
Will return Err(Error::FromValueError(v))
if could not convert v
to Self
.
sourcefn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
Will return Err(Error::FromValueError(v))
if v
is not convertible to Self
.
Implementations on Foreign Types§
source§impl FromValue for NaiveDateTime
Available on crate feature chrono
only.
impl FromValue for NaiveDateTime
chrono
only.type Intermediate = ParseIr<NaiveDateTime>
source§impl FromValue for BigDecimal
Available on crate feature bigdecimal02
only.
impl FromValue for BigDecimal
bigdecimal02
only.type Intermediate = ParseIr<BigDecimal>
source§impl FromValue for Date
Available on crate feature time
only.
impl FromValue for Date
time
only.type Intermediate = ParseIr<Date>
source§impl FromValue for f64
impl FromValue for f64
type Intermediate = ParseIrOpt<f64>
source§impl FromValue for u8
impl FromValue for u8
type Intermediate = ParseIrOpt<u8>
source§impl FromValue for NaiveTime
Available on crate feature chrono
only.
impl FromValue for NaiveTime
chrono
only.type Intermediate = ParseIr<NaiveTime>
source§impl FromValue for u64
impl FromValue for u64
type Intermediate = ParseIrOpt<u64>
source§impl FromValue for u32
impl FromValue for u32
type Intermediate = ParseIrOpt<u32>
source§impl FromValue for bool
impl FromValue for bool
type Intermediate = ParseIrOpt<bool>
source§impl FromValue for i8
impl FromValue for i8
type Intermediate = ParseIrOpt<i8>
source§impl FromValue for isize
impl FromValue for isize
type Intermediate = ParseIrOpt<isize>
source§impl FromValue for Date
Available on crate feature time02
only.
impl FromValue for Date
time02
only.type Intermediate = ParseIr<Date>
source§impl FromValue for Duration
impl FromValue for Duration
type Intermediate = ParseIrOpt<Duration>
source§impl FromValue for Time
Available on crate feature time02
only.
impl FromValue for Time
time02
only.Converts a MySQL TIME
value to a time02::Time
.
Note: time02::Time
only allows for time values in the 00:00:00 - 23:59:59 range.
If you’re expecting TIME
values in MySQL’s TIME
value range of -838:59:59 - 838:59:59,
use time02::Duration
instead.
type Intermediate = ParseIr<Time>
source§impl FromValue for PrimitiveDateTime
Available on crate feature time02
only.
impl FromValue for PrimitiveDateTime
time02
only.type Intermediate = ParseIr<PrimitiveDateTime>
source§impl FromValue for u128
impl FromValue for u128
type Intermediate = ParseIrOpt<u128>
source§impl FromValue for NaiveDate
Available on crate feature chrono
only.
impl FromValue for NaiveDate
chrono
only.type Intermediate = ParseIr<NaiveDate>
source§impl FromValue for Time
Available on crate feature time
only.
impl FromValue for Time
time
only.Converts a MySQL TIME
value to a time::Time
.
Note: time::Time
only allows for time values in the 00:00:00 - 23:59:59 range.
If you’re expecting TIME
values in MySQL’s TIME
value range of -838:59:59 - 838:59:59,
use time::Duration instead.
type Intermediate = ParseIr<Time>
source§impl FromValue for BigDecimal
Available on crate feature bigdecimal
only.
impl FromValue for BigDecimal
bigdecimal
only.type Intermediate = ParseIr<BigDecimal>
source§impl FromValue for u16
impl FromValue for u16
type Intermediate = ParseIrOpt<u16>
source§impl FromValue for Duration
Available on crate feature time
only.
impl FromValue for Duration
time
only.type Intermediate = ParseIr<Duration>
source§impl FromValue for i64
impl FromValue for i64
type Intermediate = ParseIrOpt<i64>
source§impl FromValue for usize
impl FromValue for usize
type Intermediate = ParseIrOpt<usize>
source§impl FromValue for i16
impl FromValue for i16
type Intermediate = ParseIrOpt<i16>
source§impl FromValue for Decimal
Available on crate feature rust_decimal
only.
impl FromValue for Decimal
rust_decimal
only.type Intermediate = ParseIr<Decimal>
source§impl FromValue for i128
impl FromValue for i128
type Intermediate = ParseIrOpt<i128>
source§impl FromValue for PrimitiveDateTime
Available on crate feature time
only.
impl FromValue for PrimitiveDateTime
time
only.