pub trait DeserializeValue<'frame, 'metadata>where
Self: Sized,{
// Required methods
fn type_check(typ: &ColumnType<'_>) -> Result<(), TypeCheckError>;
fn deserialize(
typ: &'metadata ColumnType<'metadata>,
v: Option<FrameSlice<'frame>>,
) -> Result<Self, DeserializationError>;
}
Expand description
A type that can be deserialized from a column value inside a row that was returned from a query.
For tips on how to write a custom implementation of this trait, see the documentation of the parent module.
The crate also provides a derive macro which allows to automatically implement the trait for a custom type. For more details on what the macro is capable of, see its documentation.
Required Methods§
Sourcefn type_check(typ: &ColumnType<'_>) -> Result<(), TypeCheckError>
fn type_check(typ: &ColumnType<'_>) -> Result<(), TypeCheckError>
Checks that the column type matches what this type expects.
Sourcefn deserialize(
typ: &'metadata ColumnType<'metadata>,
v: Option<FrameSlice<'frame>>,
) -> Result<Self, DeserializationError>
fn deserialize( typ: &'metadata ColumnType<'metadata>, v: Option<FrameSlice<'frame>>, ) -> Result<Self, DeserializationError>
Deserialize a column value from given serialized representation.
This function can assume that the driver called type_check
to verify
the column’s type. Note that deserialize
is not an unsafe function,
so it should not use the assumption about type_check
being called
as an excuse to run unsafe
code.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.