ToSpanner

Trait ToSpanner 

Source
pub trait ToSpanner {
    // Required methods
    fn to_spanner(&self) -> Result<Value, Error>;
    fn spanner_type() -> Type
       where Self: Sized;
}
Expand description

A trait for Rust types that can be converted to Cloud Spanner values.

§Types

The crate provides the following mapping between Cloud Spanner types and Rust types.

Rust TypeSpanner Type
boolBOOL
u8, i8, u16, i16, u32, i32, i64INT64
f64FLOAT64
&str, StringSTRING
&[u8], BytesBYTES

The following are provided when the corresponding feature is enabled:

FeatureRust TypeSpanner Type
jsonserde_json::ValueJSON
numericbigdecimal::BigDecimalNUMERIC
temporalchrono::DateTime<Utc>TIMESTAMP
temporalchrono::NaiveDateDATE

§Nullability

ToSpanner is implemented for Option<T> when T implements ToSpanner. Option<T> represents a nullable Spanner value.

§Arrays

ToSpanner is implemented for Vec<T> when T implements ToSpanner. Such values map to Spanner’s Array type. Arrays may contain null values (i.e.: Vec<Option<T>>). Note that Vec<Vec<T>> is not allowed.

Required Methods§

Source

fn to_spanner(&self) -> Result<Value, Error>

Creates a new Cloud Spanner value from this value.

Source

fn spanner_type() -> Type
where Self: Sized,

Returns the Cloud Spanner Type that this implementation produces.

Implementations on Foreign Types§

Source§

impl ToSpanner for &str

Source§

impl ToSpanner for Value

Source§

impl ToSpanner for i8

Source§

impl ToSpanner for i16

Source§

impl ToSpanner for i32

Source§

impl ToSpanner for i64

Source§

impl ToSpanner for u8

Source§

impl ToSpanner for u16

Source§

impl ToSpanner for u32

Source§

impl ToSpanner for String

Source§

impl ToSpanner for BigDecimal

Source§

impl ToSpanner for Bytes

Source§

impl ToSpanner for DateTime<Utc>

Source§

impl ToSpanner for NaiveDate

Source§

impl<T> ToSpanner for &[T]
where T: ToSpanner,

Source§

impl<T> ToSpanner for Option<T>
where T: ToSpanner,

Source§

impl<T> ToSpanner for Vec<T>
where T: ToSpanner,

Implementors§