Trait spanner_rs::ToSpanner
source · [−]pub trait ToSpanner {
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 Type | Spanner Type |
---|---|
bool | BOOL |
u8 , i8 , u16 , i16 , u32 , i32 , i64 | INT64 |
f64 | FLOAT64 |
&str , String | STRING |
&[u8] , Bytes | BYTES |
The following are provided when the corresponding feature is enabled:
Feature | Rust Type | Spanner Type |
---|---|---|
json | serde_json::Value | JSON |
numeric | bigdecimal::BigDecimal | NUMERIC |
temporal | chrono::DateTime<Utc> | TIMESTAMP |
temporal | chrono::NaiveDate | DATE |
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
sourcefn to_spanner(&self) -> Result<Value, Error>
fn to_spanner(&self) -> Result<Value, Error>
Creates a new Cloud Spanner value from this value.
sourcefn spanner_type() -> Typewhere
Self: Sized,
fn spanner_type() -> Typewhere
Self: Sized,
Returns the Cloud Spanner Type that this implementation produces.