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 Values with proper return types.

See:

Variants

None

Value was NULL in the database.

Bool(bool)
String(String)
Bytes(Vec<u8>)
Int(i64)
UInt(u64)
Float(f32)
Double(f64)

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Will panic if could not convert v to Self.

Will return Err(Error::FromValueError(v)) if could not convert v to Self.

Will return Err(Error::FromValueError(v)) if v is not convertible to Self.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.