Skip to main content

SqlxValue

Trait SqlxValue 

Source
pub trait SqlxValue: Sized {
    const KIND: ColumnKind;

    // Required methods
    fn null() -> SqlValue;
    fn into_sql_value(self) -> SqlValue;
    fn from_sql_value(value: SqlValue) -> Result<Self, ValueTypeError>;

    // Provided method
    fn prepare(self, _engine: Engine) -> AuthResult<Self> { ... }
}
Expand description

A model field type which converts to and from a bound SqlValue.

Conversions preserve the field representation: strings accept TEXT and explicitly selected bpchar values; optional fields accept their typed NULL. AuthEntity uses this to stage additional fields and to materialize models without a database round trip.

Required Associated Constants§

Source

const KIND: ColumnKind

The column category used to coerce configured raw values.

Required Methods§

Source

fn null() -> SqlValue

The typed NULL of this field type.

Source

fn into_sql_value(self) -> SqlValue

Source

fn from_sql_value(value: SqlValue) -> Result<Self, ValueTypeError>

§Errors

Returns an error if the value has a different type.

Provided Methods§

Source

fn prepare(self, _engine: Engine) -> AuthResult<Self>

Prepare a staged value for engine, after application hooks and before the write. JSON metadata binds exact JavaScript text on SQLite; every other value is bound unchanged.

§Errors

Returns an error if the value cannot be serialized for engine.

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 SqlxValue for DateTime<Utc>

Source§

impl SqlxValue for NaiveDateTime

Source§

const KIND: ColumnKind = ColumnKind::NaiveTimestamp

Source§

fn null() -> SqlValue

Source§

fn into_sql_value(self) -> SqlValue

Source§

fn from_sql_value(value: SqlValue) -> Result<Self, ValueTypeError>

Source§

impl SqlxValue for String

Source§

impl SqlxValue for Uuid

Source§

impl SqlxValue for Value

Source§

impl SqlxValue for Vec<u8>

Source§

impl SqlxValue for bool

Source§

impl SqlxValue for f32

Source§

impl SqlxValue for f64

Source§

impl SqlxValue for i32

Source§

impl SqlxValue for i64

Source§

impl<T: SqlxValue> SqlxValue for Option<T>

Implementors§

Source§

impl SqlxValue for ApiKeyStart

Source§

const KIND: ColumnKind = ColumnKind::Text

Source§

impl SqlxValue for Integer

Source§

const KIND: ColumnKind = ColumnKind::BigInt

Source§

impl SqlxValue for JsonMetadata

Source§

const KIND: ColumnKind = ColumnKind::Json

Source§

impl SqlxValue for Number

Source§

const KIND: ColumnKind = ColumnKind::Number