Crate sqlx_pg_uint

Source
Expand description

§sqlx-pg-uint

SQLx extension to support working with Rust unsigned integers in PostgreSQL.


This crate provides types with sqlx::{Encode, Decode, Type} implemented for them, which allow you to work with fixed-size unsigned integers in PostgreSQL.

use sqlx_pg_uint::PgU64;

let a_u64_number = 2937854645u64;
let pg_u_64 = PgU64::from(a_u64_number);
println!("PgU64: {}", pg_u_64);
let back_to_u64: u64 = pg_u_64.to_uint();
println!("Back to u64: {}", back_to_u64);
println!(
    "Maths work the same way as you'd expect: {}",
    PgU64::from(67) + PgU64::from(2) * PgU64::from(3) / PgU64::from(3)
);
println!(
    "Interact with the underlying BigDecimal type directly: {}",
    pg_u_64.as_big_decimal()
);
println!("PgUint types can be converted to and from BigDecimals, and are storable in an sqlx::Postgres database.");
println!("If you load a PgUint from a database successfully, you can be sure that it's a valid fixed-size unsigned integer.");

Structs§

PgU8
PostgreSQL-compatible unsigned 8-bit integer
PgU16
PostgreSQL-compatible unsigned 16-bit integer
PgU32
PostgreSQL-compatible unsigned 32-bit integer
PgU64
PostgreSQL-compatible unsigned 64-bit integer
PgU128
PostgreSQL-compatible unsigned 128-bit integer

Enums§

Error
Error type for conversions between BigDecimal and PgUint types.

Traits§

OptionPgUint
Allows for converting an Option<PgUInt> to an Option<[underlying integer type]>
UIntType
Helper trait to define the underlying integer type for a given PgUint type. Used in the sqlx-pg-uint-macros crate to generate the necessary code for the UIntWrapper derive.