pub trait FromSpanner<'a>: Sized {
    fn from_spanner(value: &'a Value) -> Result<Self, Error>;

    fn from_spanner_null(tpe: &Type) -> Result<Self, Error> { ... }
    fn from_spanner_nullable(value: &'a Value) -> Result<Self, Error> { ... }
}
Expand description

A trait for Rust types that can be converted from 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

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

Arrays

FromSpanner is implemented for Vec<T> when T implements FromSpanner. 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

Creates a new value of this type from the provided Cloud Spanner value. Values passed to this method should not be Value::Null, if this is not known to be the case, use FromSpanner::from_spanner_nullable instead.

Provided Methods

Creates a new value of this type from the provided Cloud Spanner NULL value’s type.

Creates a new value of this type from the provided Cloud Spanner value which may or may not be null. This method will dispatch to either FromSpanner::from_spanner or FromSpanner::from_spanner_null depending on whether the provided value is NULL.

Implementations on Foreign Types

Implementors