Derive Macro pgx_macros::PostgresType
source · #[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_received: i64,
pets_gotten: i64,
}
#[derive(Debug, Serialize, Deserialize, PostgresType)]
enum Animal {
Dog(Dog),
}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 thePgVarlenaof this type.sql: Same arguments as#[pgx(sql = ..)].