Skip to main content

FromValue

Trait FromValue 

Source
pub trait FromValue: Sized {
    const TYPE_NAME: &'static str;

    // Required method
    fn from_value(value: Value, column: &str) -> Result<Self>;
}
Expand description

Types that can be read out of a result column.

Decoding is lenient in the way SQLite users expect: integers decode into booleans (0 / 1), reals accept integers, text parses into dates, UUIDs and JSON, and blobs or text decode into UUIDs. Option<T> maps NULL to None; any other type rejects NULL.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

The name used in error messages.

Required Methods§

Source

fn from_value(value: Value, column: &str) -> Result<Self>

Decodes a value; column is only used for error messages.

§Errors

Returns Error::Decode when the value’s storage class or content cannot be converted to Self.

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 DateTime<FixedOffset>

Available on crate feature with-chrono only.
Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Accepts Unix seconds as an integer, RFC 3339, the space-separated forms with an offset, and any naive form, which is taken as UTC.

Source§

const TYPE_NAME: &'static str = "DateTime<FixedOffset>"

Source§

impl FromValue for DateTime<Utc>

Available on crate feature with-chrono only.
Source§

const TYPE_NAME: &'static str = "DateTime<Utc>"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for Decimal

Available on crate feature with-rust_decimal only.
Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Parses text exactly and converts integers and reals, the latter with the precision loss inherent to binary floats.

Source§

const TYPE_NAME: &'static str = "Decimal"

Source§

impl FromValue for NaiveDate

Available on crate feature with-chrono only.
Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Parses YYYY-MM-DD, falling back to the date part of any timestamp format NaiveDateTime accepts.

Source§

const TYPE_NAME: &'static str = "NaiveDate"

Source§

impl FromValue for NaiveDateTime

Available on crate feature with-chrono only.
Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Accepts Unix seconds as an integer, the space- and T-separated forms with or without fractions and seconds, RFC 3339 reduced to UTC, and a bare date at midnight.

Source§

const TYPE_NAME: &'static str = "NaiveDateTime"

Source§

impl FromValue for NaiveTime

Available on crate feature with-chrono only.
Source§

const TYPE_NAME: &'static str = "NaiveTime"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for String

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Decodes text as is, numbers through their Display form and blobs as UTF-8.

Source§

const TYPE_NAME: &'static str = "String"

Source§

impl FromValue for Uuid

Available on crate feature with-uuid only.
Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Accepts the hyphenated or simple text forms and 16-byte blobs.

Source§

const TYPE_NAME: &'static str = "Uuid"

Source§

impl FromValue for Value

Available on crate feature with-json only.
Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Parses text and blobs as JSON documents and maps scalars, including NULL, to the corresponding JSON value.

Source§

const TYPE_NAME: &'static str = "serde_json::Value"

Source§

impl FromValue for Vec<u8>

Source§

const TYPE_NAME: &'static str = "Vec<u8>"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for bool

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Decodes any non-zero number as true, and the usual textual spellings case-insensitively; empty text is false.

Source§

const TYPE_NAME: &'static str = "bool"

Source§

impl FromValue for f32

Source§

const TYPE_NAME: &'static str = "f32"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for f64

Source§

const TYPE_NAME: &'static str = "f64"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for i8

Source§

const TYPE_NAME: &'static str = "i8"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for i16

Source§

const TYPE_NAME: &'static str = "i16"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for i32

Source§

const TYPE_NAME: &'static str = "i32"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for i64

Source§

const TYPE_NAME: &'static str = "i64"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for isize

Source§

const TYPE_NAME: &'static str = "isize"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for u8

Source§

const TYPE_NAME: &'static str = "u8"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for u16

Source§

const TYPE_NAME: &'static str = "u16"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for u32

Source§

const TYPE_NAME: &'static str = "u32"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for u64

Source§

const TYPE_NAME: &'static str = "u64"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

impl FromValue for usize

Source§

const TYPE_NAME: &'static str = "usize"

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Source§

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

Source§

const TYPE_NAME: &'static str = T::TYPE_NAME

Source§

fn from_value(value: Value, column: &str) -> Result<Self>

Implementors§

Source§

impl FromValue for turso_orm_driver::Value

Source§

const TYPE_NAME: &'static str = "Value"