Skip to navigation
Postgres type to rust type
22.02.23
PostgreSQL Type Description Diesel Type Rust Type Nullable Types nullable Nullable
Option
Numeric Types smallint, int2 signed integer SmallInt i16 integer, int, int4 signed integer Integer i32 bigint, int8 signed integer BigInt i64 numeric(p, s), decimal(p, s) exact numeric of selectable precision Numeric bigdecimal::BigDecimal real, float4 single precision floating-point number Float f32 double precision, float8 double precision floating-point number Double f64 smallserial, serial2 autoincrementing integer SmallInt i16 serial, serial4 autoincrementing integer Integer i32 bigserial, serial8 autoincrementing integer BigInt i64 Monetary Types money currency amount Money Cents Character Types character varying(n), varchar(n) variable-length character string Text String, &str character(n), char(n) fixed-length character string Text String, &str text variable-length character string Text String, &str Binary Data Types bytea binary data (“byte array”) Binary Vec
, &u8 Date/Time Types timestamp, timestamp(p) without time zone date and time of day Timestamp chrono::NaiveDateTime timestamptz, timestamp(p) with time zone date and time of day, with time zone Timestamptz chrono::DateTime date calendar date (year, month, day) Date chrono::NaiveDate time, time(p) without time zone time of day (no date) Time chrono::NaiveTime timetz, time(p) with time zone time of day (no date), with time zone interval(fields)(p) time span Interval PgInterval Boolean Type boolean, bool logical Boolean (true/false) Bool bool Geometric Types point (x,y) geometric point on a plane line {A,B,C} infinite line on a plane lseg ((x1,y1),(x2,y2)) finite line segment on a plane box ((x1,y1),(x2,y2)) rectangular box on a plane path ((x1,y1),...) closed geometric path on a plane path [(x1,y1),...] open geometric path on a plane polygon ((x1,y1),...) closed geometric path on a plane circle <(x,y),r\> circle on a plane Network Address Types cidr IPv4 or IPv6 network address Cidr ipnetwork::IpNetwork inet IPv4 or IPv6 host address Inet ipnetwork::IpNetwork macaddr MAC address MacAddr [u8; 6] macaddr8 MAC address (EUI-64 format) Enumerated Types enum enumerated value (user-defined) String, enum Bit String Types bit(n) fixed-length bit string bit varying(n), varbit variable-length bit string Text Search Types tsvector text search document TsVector tsquery text search query TsQuery UUID Type uuid universally unique identifier Uuid uuid::Uuid XML Type xml XML data JSON Types json textual JSON data Json serde_json::Value jsonb binary JSON data, decomposed Jsonb serde_json::Value Arrays t[] array of values Array
Vec
, Vec
>, &[T], &[Option
] Range Types int4range range of integer Range
(Bound
, Bound
) int8range range of bigint Range
(Bound
, Bound
) numrange range of numeric Range
(Bound
, Bound
) tsrange range of timestamp Range
(Bound
, Bound
) tstzrange range of timestamptz Range
(Bound
, Bound
) daterange range of date Range
(Bound
, Bound
)
https://kotiri.com/2018/01/31/postgresql-diesel-rust-types.html
Reply
Anonymous
Information Epoch 1742298590
Save trees.
Home
Notebook
Contact us