[−][src]Trait mysql_async::prelude::FromValue
Implement this trait to convert value to something.
FromRow
requires ability to cheaply rollback FromValue
conversion. This ability is
provided via Intermediate
associated type.
Example implementation:
ⓘThis example is not tested
#[derive(Debug)] pub struct StringIr { bytes: Vec<u8>, } impl ConvIr<String> for StringIr { fn new(v: Value) -> MyResult<StringIr> { match v { Value::Bytes(bytes) => match from_utf8(&*bytes) { Ok(_) => Ok(StringIr { bytes: bytes }), Err(_) => Err(Error::FromValueError(Value::Bytes(bytes))), }, v => Err(Error::FromValueError(v)), } } fn commit(self) -> String { unsafe { String::from_utf8_unchecked(self.bytes) } } fn rollback(self) -> Value { Value::Bytes(self.bytes) } } impl FromValue for String { type Intermediate = StringIr; }
Associated Types
type Intermediate: ConvIr<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
.
Implementations on Foreign Types
impl FromValue for BigDecimal
[src]
type Intermediate = ParseIr<BigDecimal>
fn from_value(v: Value) -> BigDecimal
[src]
impl FromValue for i16
[src]
type Intermediate = ParseIr<i16>
impl FromValue for u32
[src]
type Intermediate = ParseIr<u32>
impl FromValue for bool
[src]
type Intermediate = ParseIr<bool>
impl FromValue for i64
[src]
type Intermediate = ParseIr<i64>
impl<T> FromValue for Option<T> where
T: FromValue,
[src]
T: FromValue,
type Intermediate = OptionIr<<T as FromValue>::Intermediate>
impl FromValue for Duration
[src]
type Intermediate = ParseIr<Duration>
impl FromValue for BigUint
[src]
type Intermediate = ParseIr<BigUint>
fn from_value(v: Value) -> BigUint
[src]
impl FromValue for Vec<u8>
[src]
type Intermediate = BytesIr
impl FromValue for String
[src]
type Intermediate = StringIr
impl FromValue for u128
[src]
type Intermediate = ParseIr<u128>
impl FromValue for Uuid
[src]
type Intermediate = UuidIr
impl FromValue for u8
[src]
type Intermediate = ParseIr<u8>
impl FromValue for i8
[src]
type Intermediate = ParseIr<i8>
impl FromValue for usize
[src]
type Intermediate = ParseIr<usize>
impl FromValue for Decimal
[src]
type Intermediate = ParseIr<Decimal>
fn from_value(v: Value) -> Decimal
[src]
impl FromValue for NaiveDate
[src]
type Intermediate = ParseIr<NaiveDate>
impl FromValue for isize
[src]
type Intermediate = ParseIr<isize>
impl FromValue for Timespec
[src]
type Intermediate = ParseIr<Timespec>
impl FromValue for u16
[src]
type Intermediate = ParseIr<u16>
impl FromValue for f64
[src]
type Intermediate = ParseIr<f64>
impl FromValue for BigInt
[src]
type Intermediate = ParseIr<BigInt>
fn from_value(v: Value) -> BigInt
[src]
impl FromValue for NaiveDateTime
[src]
type Intermediate = ParseIr<NaiveDateTime>
impl FromValue for Value
[src]
type Intermediate = JsonIr
impl FromValue for Duration
[src]
type Intermediate = ParseIr<Duration>
impl FromValue for u64
[src]
type Intermediate = ParseIr<u64>
impl FromValue for i32
[src]
type Intermediate = ParseIr<i32>
impl FromValue for f32
[src]
type Intermediate = ParseIr<f32>
impl FromValue for NaiveTime
[src]
type Intermediate = ParseIr<NaiveTime>
impl FromValue for i128
[src]
type Intermediate = ParseIr<i128>
Implementors
impl FromValue for mysql_async::Value
[src]
type Intermediate = Value
fn from_value(v: Value) -> Value
[src]
fn from_value_opt(v: Value) -> Result<Value, FromValueError>
[src]
impl<T> FromValue for Deserialized<T> where
T: DeserializeOwned,
[src]
T: DeserializeOwned,