Skip to main content

Cast

Trait Cast 

Source
pub trait Cast: Sized {
    const COLUMNS: &'static [ColumnSpec];
    const NULLABLE: bool = false;
    const SENSITIVE: bool = false;
    const MOVES: Option<Moves<Self>> = None;
    const HOLDS_STATES: bool = _;

    // Required methods
    fn encode(&self, out: &mut Vec<SqlValue>);
    fn decode(row: &mut dyn ColumnReader) -> Result<Self>;

    // Provided method
    fn refuse_unlisted_move(
        field: &str,
        stored: &Self,
        current: &Self,
    ) -> Result<()> { ... }
}

Required Associated Constants§

Source

const COLUMNS: &'static [ColumnSpec]

Provided Associated Constants§

Source

const NULLABLE: bool = false

Source

const SENSITIVE: bool = false

A field holding it is never filtered, sorted, listed or searched, as #[sensitive] ones.

Source

const MOVES: Option<Moves<Self>> = None

Set for a value moving between listed states; a save of any other value skips the check.

Source

const HOLDS_STATES: bool = _

Set when a state anywhere in the value is checked on save, as a field’s of several.

Required Methods§

Source

fn encode(&self, out: &mut Vec<SqlValue>)

Source

fn decode(row: &mut dyn ColumnReader) -> Result<Self>

Provided Methods§

Source

fn refuse_unlisted_move( field: &str, stored: &Self, current: &Self, ) -> Result<()>

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

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

fn encode(&self, out: &mut Vec<SqlValue>)

Source§

fn decode(row: &mut dyn ColumnReader) -> Result<Self>

Source§

impl Cast for bool

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

fn encode(&self, out: &mut Vec<SqlValue>)

Source§

fn decode(row: &mut dyn ColumnReader) -> Result<Self>

Source§

impl Cast for f64

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

fn encode(&self, out: &mut Vec<SqlValue>)

Source§

fn decode(row: &mut dyn ColumnReader) -> Result<Self>

Source§

impl Cast for i32

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

fn encode(&self, out: &mut Vec<SqlValue>)

Source§

fn decode(row: &mut dyn ColumnReader) -> Result<Self>

Source§

impl Cast for i64

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

fn encode(&self, out: &mut Vec<SqlValue>)

Source§

fn decode(row: &mut dyn ColumnReader) -> Result<Self>

Source§

impl<T: Cast> Cast for Option<T>

Only all-null columns read back as None, so an Option of a value that can be all nulls (an Option, or a value of several fields that are all optional) is refused when compiled:

ⓘ
use sofie_core::Cast;

let _ = <Option<Option<i64>>>::COLUMNS;
Source§

const COLUMNS: &'static [ColumnSpec]

Source§

const NULLABLE: bool = true

Source§

const SENSITIVE: bool = T::SENSITIVE

Source§

const MOVES: Option<Moves<Self>>

Source§

const HOLDS_STATES: bool = T::HOLDS_STATES

Source§

fn encode(&self, out: &mut Vec<SqlValue>)

Source§

fn decode(row: &mut dyn ColumnReader) -> Result<Self>

Source§

fn refuse_unlisted_move( field: &str, stored: &Self, current: &Self, ) -> Result<()>

Implementors§

Source§

impl Cast for Date

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

impl Cast for DateTime

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

impl Cast for Timestamp

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

impl Cast for Uuid

Source§

const COLUMNS: &'static [ColumnSpec]

Source§

impl<V: Value> Cast for V

Source§

const COLUMNS: &'static [ColumnSpec] = <V::Inner>::COLUMNS

Source§

const NULLABLE: bool = <V::Inner>::NULLABLE

Source§

const SENSITIVE: bool