Skip to main content

FromSql

Trait FromSql 

Source
pub trait FromSql: Sized {
    // Required method
    fn from_sql(value: Value) -> Result<Self, ConvertError>;
}
Expand description

A trait for converting BigQuery wkt::Value representations into Rust types.

Row::get() and Row::try_get() use this trait to convert cell values, and the FromRow derive macro uses it for field deserialization.

§Supported Types

Built-in implementations include:

§Example

let mut rows = client
    .query("SELECT 12345 AS integer_col, 'foo' AS string_col")
    .until_done()
    .await?
    .read();

while let Some(row) = rows.next().await.transpose()? {
    let num: i64 = row.get("integer_col");
    let txt: String = row.get("string_col");
    println!("{txt}: {num}");
}

Required Methods§

Source

fn from_sql(value: Value) -> Result<Self, ConvertError>

Converts a BigQuery wkt::Value into the implementing type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromSql for Bytes

Source§

impl FromSql for Date

Source§

impl FromSql for DateTime

Source§

impl FromSql for Decimal

Source§

impl FromSql for Decimal

Source§

impl FromSql for String

Source§

impl FromSql for Struct

Source§

impl FromSql for TimeOfDay

Source§

impl FromSql for Timestamp

Source§

impl FromSql for Value

Source§

impl FromSql for Vec<u8>

Source§

impl FromSql for bool

Source§

impl FromSql for f32

Source§

impl FromSql for f64

Source§

impl FromSql for i32

Source§

impl FromSql for i64

Source§

impl<T: FromSql> FromSql for Option<T>

Source§

impl<T: FromSql> FromSql for Vec<T>

Implementors§