Skip to main content

ValueSqlType

Trait ValueSqlType 

Source
pub trait ValueSqlType:
    SqlType<IsNull = NotNull>
    + SingleValue
    + Sized {
    type Rust: AsExpression<Self> + Send + 'static;

    const ACCEPTS: &'static [ValueKind];

    // Required method
    fn rust(value: Value) -> Result<Option<Self::Rust>, Value>;
}
Expand description

A non-null SQL type a domain value binds as: the Rust type it binds, taken from a Value.

Implemented for Diesel’s SQL types queryweave’s values fit, each accepting the variants it holds without loss (an Integer column takes I32 and I16; a Timestamp column a NaiveDateTime, or a UTC DateTimeUtc as its naive UTC time). Implement it for a SQL type of your own (with Comparison and ColumnValue) to filter and write its columns.

Required Associated Constants§

Source

const ACCEPTS: &'static [ValueKind]

The Value variants rust takes, for the compile-time check that a domain field’s value fits its column.

Required Associated Types§

Source

type Rust: AsExpression<Self> + Send + 'static

The Rust type the value binds as.

Required Methods§

Source

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

The value as this SQL type’s Rust type (None for a NULL).

§Errors

The value itself, if it is of another type.

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 ValueSqlType for BigInt

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = i64

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Source§

impl ValueSqlType for Bool

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = bool

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Source§

impl ValueSqlType for Date

Source§

impl ValueSqlType for Datetime

Source§

impl ValueSqlType for Double

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = f64

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Source§

impl ValueSqlType for Float

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = f32

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Source§

impl ValueSqlType for Integer

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = i32

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Source§

impl ValueSqlType for SmallInt

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = i16

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Source§

impl ValueSqlType for Text

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = String

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Source§

impl ValueSqlType for Time

Source§

impl ValueSqlType for Timestamp

Source§

impl ValueSqlType for Timestamptz

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = DateTime<Utc>

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Source§

impl ValueSqlType for TimestamptzSqlite

Source§

const ACCEPTS: &'static [ValueKind]

Source§

type Rust = DateTime<Utc>

Source§

fn rust(value: Value) -> Result<Option<Self::Rust>, Value>

Implementors§