Derive Macro tokio_postgres_utils::FromRow
source · #[derive(FromRow)]
Expand description
Implements From<&Row>
trait for a struct, allowing direct conversion from a database row to the struct.
§Example
use tokio_postgres_utils::FromRow;
#[derive(FromRow)]
struct User {
id: i32,
name: String,
}
Expand into:
impl From<&Row> for User {
fn from(row: &Row) -> Self {
Self {
id: row.get("id"),
name: row.get("name"),
}
}
}