Skip to main content

ColumnValue

Trait ColumnValue 

Source
pub trait ColumnValue: Sized + 'static {
    const SQL_TYPE: SqlType;

    // Required methods
    fn to_sqlite_value(&self) -> Value;
    fn from_sqlite_value(v: Value) -> Result<Self, DbError>;
}
Expand description

A Rust type that knows how to be a column. One impl per type: its canonical form.

Required Associated Constants§

Source

const SQL_TYPE: SqlType

The declared column type. Part of the schema fingerprint, so changing it is a migration, never a surprise.

Required Methods§

Source

fn to_sqlite_value(&self) -> Value

Source

fn from_sqlite_value(v: Value) -> Result<Self, DbError>

Decode the stored value.

§Errors

Returns a decoding error when v is not a value this type stores.

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 ColumnValue for String

Source§

impl ColumnValue for Uuid

A Uuid is a 16-byte BLOB: compact, indexable, and readable by any tool that knows the convention. (day_model::Uuid is uuid::Uuid, so no second dependency edge exists.)

Source§

impl ColumnValue for Vec<u8>

Source§

impl ColumnValue for bool

Source§

impl ColumnValue for f32

Source§

impl ColumnValue for f64

Source§

impl ColumnValue for i8

Source§

impl ColumnValue for i16

Source§

impl ColumnValue for i32

Source§

impl ColumnValue for i64

Source§

impl ColumnValue for isize

Source§

impl ColumnValue for u8

Source§

impl ColumnValue for u16

Source§

impl ColumnValue for u32

Source§

impl ColumnValue for u64

Source§

impl ColumnValue for usize

Source§

impl<T: ColumnValue> ColumnValue for Option<T>

NULL belongs to the framework: Option wraps any column type, encoding is called only on present values, and a NULL decodes to None, so an impl never sees Null and cannot disagree about it.

Implementors§

Source§

impl ColumnValue for Blob

Source§

const SQL_TYPE: SqlType = SqlType::Blob

Source§

impl<M: Model> ColumnValue for One<M>

Source§

const SQL_TYPE: SqlType = M::KEY_SQL