Skip to main content

Crate use_pg_type

Crate use_pg_type 

Source
Expand description

§use-pg-type

PostgreSQL type primitives for RustUse.

This crate provides type-name labels, broad type categories, common built-in type labels, array-like labels, and an optional primitive OID wrapper. It does not bind built-in labels to live PostgreSQL catalog OIDs.

§Example

use use_pg_type::{PgBuiltInType, PgTypeCategory, PgTypeName, PgTypeOid};

let ty: PgBuiltInType = "timestamptz".parse()?;
let text = PgTypeName::built_in(PgBuiltInType::Text);
let text_array = PgTypeName::array_of(&text);
let oid = PgTypeOid::new(23)?;

assert_eq!(ty.to_string(), "timestamp with time zone");
assert_eq!(PgBuiltInType::Jsonb.category(), PgTypeCategory::Json);
assert_eq!(text_array.to_string(), "text[]");
assert_eq!(oid.get(), 23);

Structs§

PgTypeName
A PostgreSQL type name label.
PgTypeOid
Optional primitive wrapper for a PostgreSQL type OID.

Enums§

PgBuiltInType
Common PostgreSQL built-in type labels.
PgTypeCategory
Broad PostgreSQL type categories.
PgTypeError
Error returned when PostgreSQL type metadata is invalid.