pub trait ScalarValue: Sized {
// Required method
fn from_row(row: &Row, col: usize) -> Option<Self>;
}Expand description
Trait for types that can be extracted from a scalar query result.
This trait enables the generic Connection::execute_scalar_query method,
similar to C++’s executeScalarQuery<T>() template.
§Implementing Custom Types
You can implement this trait for custom types to use them with execute_scalar_query:
impl ScalarValue for MyType {
fn from_row(row: &Row, col: usize) -> Option<Self> {
row.get_string(col).map(|s| MyType::parse(&s))
}
}Required Methods§
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.