Derive Macro sqlm_postgres::Enum
source · #[derive(Enum)]
Expand description
A derive necessary to support compile checks between Postgres and Rust enums.
In addition, enums also need to implement tokio_postgres
’s FromSql
and ToSql
, so it
can be read from and written to Postgres.
§Example
use sqlm_postgres::{Enum, FromSql, ToSql};
#[derive(Debug, Default, FromSql, ToSql, Enum)]
#[postgres(name = "role")]
enum Role {
#[default]
#[postgres(name = "user")]
User,
#[postgres(name = "admin")]
Admin,
}