Expand description
Postgres relational database storage.
You can use the into() method to convert
a Rust value into a ParameterValue. You can use the
Decode trait to convert a DbValue to a suitable Rust type.
The following table shows available conversions.
§Types
| Rust type | WIT (db-value) | Postgres type(s) |
|---|---|---|
bool | boolean(bool) | BOOL |
i16 | int16(s16) | SMALLINT, SMALLSERIAL, INT2 |
i32 | int32(s32) | INT, SERIAL, INT4 |
i64 | int64(s64) | BIGINT, BIGSERIAL, INT8 |
f32 | floating32(float32) | REAL, FLOAT4 |
f64 | floating64(float64) | DOUBLE PRECISION, FLOAT8 |
String | str(string) | VARCHAR, CHAR(N), TEXT |
Vec<u8> | binary(list<u8>) | BYTEA |
chrono::NaiveDate | date(tuple<s32, u8, u8>) | DATE |
chrono::NaiveTime | time(tuple<u8, u8, u8, u32>) | TIME |
chrono::NaiveDateTime | datetime(tuple<s32, u8, u8, u8, u8, u8, u32>) | TIMESTAMP |
chrono::Duration | timestamp(s64) | BIGINT |
uuid::Uuid | uuid(string) | UUID |
serde_json::Value | jsonb(list<u8>) | JSONB |
serde::De/Serialize | jsonb(list<u8>) | JSONB |
rust_decimal::Decimal | decimal(string) | NUMERIC |
postgres_range | range-int32(…), range-int64(…) | INT4RANGE, INT8RANGE |
| lower/upper tuple | range-decimal(…) | NUMERICRANGE |
Vec<Option<...>> | array-int32(…), array-int64(…), array-str(…), array-decimal(…) | INT4[], INT8[], TEXT[], NUMERIC[] |
pg4::Interval | interval(interval) | INTERVAL |
Re-exports§
pub use crate::pg4::Interval;
Structs§
- Column
- A database column
- Connection
- An open connection to a PostgreSQL database.
- DbError
- Interval
- Row
- A database row result.
- RowSet
- The result of a database query.
Enums§
- DbData
Type - Data types for a database column
- DbValue
- Database values
- Error
- A Postgres error
- Error
- Errors related to interacting with a database.
- Parameter
Value - Values used in parameterized queries
- PgError
- Errors related to interacting with a database.
- Query
Error - Range
Bound Kind - For range types, indicates if each bound is inclusive or exclusive
Traits§
- Decode
- A type that can be decoded from the database.
Functions§
- from_
jsonb json - Convert a Postgres JSONB value to a
Deserialize-able type. - jsonb
json - Converts a
Serializevalue to a Postgres JSONB SQL parameter.
Type Aliases§
- Row
- A database row