pub trait ZeroValue: Sized {
// Required methods
fn from_zero_value(value: &Value) -> Result<Self, ZeroValueError>;
fn to_zero_value(&self) -> Value;
// Provided method
fn value_for_null() -> Option<Self> { ... }
}Expand description
A Rust type a column holds. Generated row structs use these for their columns, and the query builder encodes compared values with them.
Required Methods§
Sourcefn from_zero_value(value: &Value) -> Result<Self, ZeroValueError>
fn from_zero_value(value: &Value) -> Result<Self, ZeroValueError>
Reads a value from a row; a missing column reads as null.
Sourcefn to_zero_value(&self) -> Value
fn to_zero_value(&self) -> Value
Writes the value as the row and the query builder hold it.
Provided Methods§
Sourcefn value_for_null() -> Option<Self>
fn value_for_null() -> Option<Self>
What a row’s null reads as when the schema says the column can’t
be null; None to fail. Databases drift from schemas, and JS shows
such a row with the null rather than failing, so strings, numbers,
and booleans read as "", 0, and false. Declare the column
optional() to read the null.
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 ZeroValue for String
impl ZeroValue for String
fn from_zero_value(value: &Value) -> Result<Self, ZeroValueError>
fn to_zero_value(&self) -> Value
fn value_for_null() -> Option<Self>
Source§impl ZeroValue for bool
impl ZeroValue for bool
fn from_zero_value(value: &Value) -> Result<Self, ZeroValueError>
fn to_zero_value(&self) -> Value
fn value_for_null() -> Option<Self>
Source§impl ZeroValue for f64
impl ZeroValue for f64
fn from_zero_value(value: &Value) -> Result<Self, ZeroValueError>
fn to_zero_value(&self) -> Value
fn value_for_null() -> Option<Self>
Source§impl ZeroValue for i64
For a number() column the codegen config declares an integer: the
value must be exact, which every integer up to 2^53 is.
impl ZeroValue for i64
For a number() column the codegen config declares an integer: the
value must be exact, which every integer up to 2^53 is.
fn from_zero_value(value: &Value) -> Result<Self, ZeroValueError>
fn to_zero_value(&self) -> Value
fn value_for_null() -> Option<Self>
Source§impl<T: ZeroValue> ZeroValue for Option<T>
An optional column: null reads as None.
impl<T: ZeroValue> ZeroValue for Option<T>
An optional column: null reads as None.
fn from_zero_value(value: &Value) -> Result<Self, ZeroValueError>
fn to_zero_value(&self) -> Value
Source§impl<T: ZeroValue> ZeroValue for Vec<T>
The JSON arrays a json() column can hold.
impl<T: ZeroValue> ZeroValue for Vec<T>
The JSON arrays a json() column can hold.