Enum mysql_async_support_model::Value [−][src]
pub enum Value { None, Bool(bool), String(String), Bytes(Vec<u8>), Int(i64), UInt(u64), Float(f32), Double(f64), Date(NaiveDateTime), Time(Duration), }
Expand description
Programmer-friendly model of MySQL [Value
][mysql_async::Value] type.
Note
- You must use prepared statements if you want types to be returned,
otherwise it is always returned as
Value::Bytes
- There must be only one statement in the query – i.e. no multiple selects.
- Not sure if nested select statements work.
However, I haven’t managed to get MySQL to return Value
s with proper
return types.
See:
Variants
Value was NULL
in the database.
Bool(bool)
String(String)
Int(i64)
UInt(u64)
Float(f32)
Double(f64)
Date(NaiveDateTime)
DateTime
without a time zone.
In mysql_async
stores this as Date(u16, u8, u8, u8, u8, u8, u32)
,
correspnding to:
year, month, day, hour, minutes, seconds, micro seconds
If you wish to attach timezone information, such as UTC, you may do something like the following:
use chrono::{NaiveDate, TimeZone, Utc}; let naive_date_time = NaiveDate::from_ymd(2021, 05, 30).and_hms_micro(12, 06, 53, 445); let _utc_date_time = Utc.from_utc_datetime(&naive_date_time);
See:
Time(Duration)
Time offset or duration.
In mysql_async
stores this as Time(bool, u32, u8, u8, u8, u32)
,
correspnding to:
is negative, days, hours, minutes, seconds, micro seconds
See:
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
type Intermediate = ValueIr
fn from_value(v: Value) -> Self
fn from_value(v: Value) -> Self
Will panic if could not convert v
to Self
.
fn 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
.
fn 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
.
Auto Trait Implementations
impl RefUnwindSafe for Value
impl UnwindSafe for Value
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn from_row_opt(row: Row) -> Result<T, FromRowError>
fn from_row(row: Row) -> Self
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V