Trait mysql_async::prelude::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
.
Object Safety§
This trait is not object safe.