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§
Sourceconst KIND: ColumnKind
const KIND: ColumnKind
The column category used to coerce configured raw values.
Required Methods§
fn into_sql_value(self) -> SqlValue
Sourcefn from_sql_value(value: SqlValue) -> Result<Self, ValueTypeError>
fn from_sql_value(value: SqlValue) -> Result<Self, ValueTypeError>
§Errors
Returns an error if the value has a different type.
Provided Methods§
Sourcefn prepare(self, _engine: Engine) -> AuthResult<Self>
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".