tokio-postgres-utils 0.1.0

Utilities to work with the `tokio-postgres` crate
Documentation

It provide utilities to work with the tokio-postgres crate, specifically through the use of FromRow and TryFromRow derive macros. These macros simplify the process of converting database rows into Rust structs.

Installation

Add tokio-postgres-utils to your Cargo.toml:

[dependencies]
tokio-postgres = "0.7"
tokio-postgres-utils = "0.1"

Example

use tokio_postgres_utils::FromRow;

#[derive(FromRow)]
struct User {
    id: i32,
    name: String,
}

Expand into something like:

use tokio_postgres::Row;

impl From<&Row> for User {
    fn from(row: &Row) -> Self {
        Self {
            id: row.get("id"),
            name: row.get("name"),
        }
    }
}