#[derive(PostgresType)]
{
    // Attributes available to this derive:
    #[inoutfuncs]
    #[pgvarlena_inoutfuncs]
    #[requires]
    #[pgx]
}
Expand description

Generate necessary bindings for using the type with PostgreSQL.

use pgx::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, PostgresType)]
struct Dog {
    treats_recieved: i64,
    pets_gotten: i64,
}

Optionally accepts the following attributes:

  • inoutfuncs(some_in_fn, some_out_fn): Define custom in/out functions for the type.
  • pgvarlena_inoutfuncs(some_in_fn, some_out_fn): Define custom in/out functions for the PgVarlena of this type.
  • sql: Same arguments as #[pgx(sql = ..)].