Skip to main content

FromValue

Trait FromValue 

Source
pub trait FromValue: Sized {
    // Required method
    fn from_value(value: &Value, type_: &Type) -> Result<Self, ConvertError>;
}
Expand description

Converts a Spanner Value into a Rust type.

Implementations are provided for all standard types like String, primitive integer and float types, decimals, timestamps, dates, vectors, and options for nullable fields.

Required Methods§

Source

fn from_value(value: &Value, type_: &Type) -> Result<Self, ConvertError>

Converts a Spanner value into the target Rust type, using the provided Spanner Type metadata for compatibility checks.

§Errors

Returns a ConvertError if the kind of the value does not match the expected kind, if the value is null but the target type is not optional (e.g., Option<T>), or if parsing or decoding the inner value format fails.

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 FromValue for Date

Source§

fn from_value(value: &Value, type_: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for OffsetDateTime

Source§

fn from_value(value: &Value, type_: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for String

Source§

fn from_value(value: &Value, _type: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for SystemTime

Source§

fn from_value(value: &Value, type_: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for Timestamp

Source§

fn from_value(value: &Value, type_: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for Vec<u8>

Source§

fn from_value(value: &Value, type_: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for bool

Source§

fn from_value(value: &Value, _type: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for f32

Source§

fn from_value(value: &Value, _type: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for f64

Source§

fn from_value(value: &Value, _type: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for i32

Source§

fn from_value(value: &Value, _type: &Type) -> Result<Self, ConvertError>

Source§

impl FromValue for i64

Source§

fn from_value(value: &Value, _type: &Type) -> Result<Self, ConvertError>

Source§

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

Source§

fn from_value(value: &Value, type_: &Type) -> Result<Self, ConvertError>

Source§

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

Source§

fn from_value(value: &Value, type: &Type) -> Result<Self, ConvertError>

Implementors§