pub trait FromQuery: Sized {
type Based: AsTable;
// Required methods
fn select_sql() -> String;
fn from_row(row: &Row<'_>) -> Result<Self, Error>;
}Available on crate feature
utils only.Expand description
Trait for types that can be deserialized from a SQL row.
Implement this trait to make a type queryable as a generic parameter of Query::query().
Typically implemented via #[derive] macros or manually on entity structs
(e.g. Post, Author).
§Associated types
Based: the corresponding database table type, must implementAsTable.
Required Associated Types§
Required Methods§
Sourcefn select_sql() -> String
fn select_sql() -> String
Returns the SELECT … SQL fragment used to query this type (without WHERE/ORDER/LIMIT).
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.