Trait mysql::prelude::FromValue [−][src]
pub trait FromValue { type Intermediate: ConvIr<Self>; fn from_value(v: Value) -> Self { ... } fn from_value_opt(v: Value) -> Result<Self, FromValueError> { ... } fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError> { ... } }
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<T> FromValue for Option<T> where
T: FromValue,
[src]
impl<T> FromValue for Option<T> where
T: FromValue,
type Intermediate = OptionIr<<T as FromValue>::Intermediate>
fn from_value(v: Value) -> Option<T>
[src]
fn from_value(v: Value) -> Option<T>
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for i8
[src]
impl FromValue for i8
type Intermediate = ParseIr<i8>
fn from_value(v: Value) -> i8
[src]
fn from_value(v: Value) -> i8
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for isize
[src]
impl FromValue for isize
type Intermediate = ParseIr<isize>
fn from_value(v: Value) -> isize
[src]
fn from_value(v: Value) -> isize
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for u16
[src]
impl FromValue for u16
type Intermediate = ParseIr<u16>
fn from_value(v: Value) -> u16
[src]
fn from_value(v: Value) -> u16
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for i64
[src]
impl FromValue for i64
type Intermediate = ParseIr<i64>
fn from_value(v: Value) -> i64
[src]
fn from_value(v: Value) -> i64
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for Duration
[src]
impl FromValue for Duration
type Intermediate = ParseIr<Duration>
fn from_value(v: Value) -> Duration
[src]
fn from_value(v: Value) -> Duration
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for u64
[src]
impl FromValue for u64
type Intermediate = ParseIr<u64>
fn from_value(v: Value) -> u64
[src]
fn from_value(v: Value) -> u64
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for String
[src]
impl FromValue for String
type Intermediate = StringIr
fn from_value(v: Value) -> String
[src]
fn from_value(v: Value) -> String
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for Value
[src]
impl FromValue for Value
type Intermediate = JsonIr
fn from_value(v: Value) -> Self
[src]
fn from_value(v: Value) -> Self
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for f32
[src]
impl FromValue for f32
type Intermediate = ParseIr<f32>
fn from_value(v: Value) -> f32
[src]
fn from_value(v: Value) -> f32
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for bool
[src]
impl FromValue for bool
type Intermediate = ParseIr<bool>
fn from_value(v: Value) -> bool
[src]
fn from_value(v: Value) -> bool
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for usize
[src]
impl FromValue for usize
type Intermediate = ParseIr<usize>
fn from_value(v: Value) -> usize
[src]
fn from_value(v: Value) -> usize
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for Vec<u8>
[src]
impl FromValue for Vec<u8>
type Intermediate = BytesIr
fn from_value(v: Value) -> Vec<u8>
[src]
fn from_value(v: Value) -> Vec<u8>
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for u8
[src]
impl FromValue for u8
type Intermediate = ParseIr<u8>
fn from_value(v: Value) -> u8
[src]
fn from_value(v: Value) -> u8
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for i32
[src]
impl FromValue for i32
type Intermediate = ParseIr<i32>
fn from_value(v: Value) -> i32
[src]
fn from_value(v: Value) -> i32
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for f64
[src]
impl FromValue for f64
type Intermediate = ParseIr<f64>
fn from_value(v: Value) -> f64
[src]
fn from_value(v: Value) -> f64
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for u32
[src]
impl FromValue for u32
type Intermediate = ParseIr<u32>
fn from_value(v: Value) -> u32
[src]
fn from_value(v: Value) -> u32
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
impl FromValue for i16
[src]
impl FromValue for i16
type Intermediate = ParseIr<i16>
fn from_value(v: Value) -> i16
[src]
fn from_value(v: Value) -> i16
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
[src]
fn from_value_opt(v: Value) -> Result<Self, FromValueError>
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
[src]
fn get_intermediate(v: Value) -> Result<Self::Intermediate, FromValueError>
Implementors
impl FromValue for Uuid type Intermediate = UuidIr;
impl<T> FromValue for Deserialized<T> where
T: DeserializeOwned, type Intermediate = DeserializedIr<T>;impl FromValue for Timespec type Intermediate = ParseIr<Timespec>;
impl FromValue for NaiveDate type Intermediate = ParseIr<NaiveDate>;
impl FromValue for NaiveTime type Intermediate = ParseIr<NaiveTime>;
impl FromValue for mysql::Value type Intermediate = Value;
impl FromValue for NaiveDateTime type Intermediate = ParseIr<NaiveDateTime>;
impl FromValue for mysql::time::Duration type Intermediate = ParseIr<Duration>;