Data types

PL/Rust provides mappings for many of the built-in PostgreSQL data types. Rust's ownership rules means that these mappings may be different based on their usage. Where it can PL/Rust borrows (zero-copy) arguments and returns owned values.

SQLPL/Rust ArgumentPL/Rust Return Type
NULLOption::NoneOption::None
"char"i8i8
biginti64i64
boolboolbool
boxBOX1BOX
bytea&[u8]Vec<u8>
cstring&CStrCString
dateDateDate
daterangeRange<Date>Range<Date>
double precisionf64f64
int4rangeRange<i32>Range<i32>
int8rangeRange<i64>Range<i64>
integeri32i32
intervalIntervalInterval
jsonJson(serde_json::Value)Json(serde_json::Value)
jsonbJsonB(serde_json::Value)JsonB(serde_json::Value)
numericAnyNumericAnyNumeric
numrangeRange<AnyNumeric>Range<AnyNumeric>
oidOidOid
pointPointPoint
realf32f32
smallinti16i16
text&strString
tidItemPointerDataItemPointerData
time with time zoneTimeWithTimeZoneTimeWithTimeZone
timeTimeTime
timestamp with time zoneTimestampWithTimeZoneTimestampWithTimeZone
timestampTimestampTimestamp
tsrangeRange<Timestamp>Range<Timestamp>
tstzrangeRange<TimestampWithTimeZone>Range<TimestampWithTimeZone>
uuidUuidUuid
varchar&strString
voidn/a()

1: This is Postgres' geometric BOX type, not to be confused with Rust's Box type, which stores allocated data on the heap