pub trait FromValue: Sized {
// Required method
fn from_value(value: &Value) -> Result<Self>;
// Provided method
fn from_value_owned(value: Value) -> Result<Self> { ... }
}Expand description
Trait for converting database values to Rust types.
This trait enables type-safe decoding of individual column values during row deserialization in the selection API.
Required Methods§
Sourcefn from_value(value: &Value) -> Result<Self>
fn from_value(value: &Value) -> Result<Self>
Convert a Value reference to this type.
Returns an error if the value is NULL, has the wrong type, or cannot be converted.
Provided Methods§
Sourcefn from_value_owned(value: Value) -> Result<Self>
fn from_value_owned(value: Value) -> Result<Self>
Convert an owned Value to this type, avoiding clones when possible.
The default implementation delegates to from_value. Types that hold
heap data (String, Json, Bytes) override this to take ownership
instead of cloning.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".