@@ -460,6 +460,48 @@ make_postgres_type! {
460460}
461461
462462/// A trait for types that can be created from a Postgres value.
463+ ///
464+ /// # Types
465+ ///
466+ /// The following implementations are provided by this crate, along with the
467+ /// corresponding Postgres types:
468+ ///
469+ /// | Rust type | Postgres type(s) |
470+ /// |---------------------------------------------|--------------------------------|
471+ /// | bool | BOOL |
472+ /// | i8 | "char" |
473+ /// | i16 | SMALLINT, SMALLSERIAL |
474+ /// | i32 | INT, SERIAL |
475+ /// | u32 | OID |
476+ /// | i64 | BIGINT, BIGSERIAL |
477+ /// | f32 | REAL |
478+ /// | f64 | DOUBLE PRECISION |
479+ /// | String | VARCHAR, CHAR(n), TEXT, CITEXT |
480+ /// | Vec<u8> | BYTEA |
481+ /// | HashMap<String, Option<String>> | HSTORE |
482+ ///
483+ /// In addition, some implementations are provided for types in third party
484+ /// crates. These are disabled by default; to opt into one of these
485+ /// implementations, activate the cargo feature corresponding to the crate's
486+ /// name. For example, the `serde` feature enables the implementation for the
487+ /// `serde::json::Value` type.
488+ ///
489+ /// | Rust type | Postgres type(s) |
490+ /// |-----------------------------|-------------------------------------|
491+ /// | serialize::json::Json | JSON, JSONB |
492+ /// | serde::json::Value | JSON, JSONB |
493+ /// | time::Timespec | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
494+ /// | chrono::NaiveDateTime | TIMESTAMP |
495+ /// | chrono::DateTime<UTC> | TIMESTAMP WITH TIME ZONE |
496+ /// | chrono::NaiveDate | DATE |
497+ /// | chrono::NaiveTime | TIME |
498+ /// | uuid::Uuid | UUID |
499+ ///
500+ /// # Nullability
501+ ///
502+ /// In addition to the types listed above, `FromSql` is implemented for
503+ /// `Option<T>` where `T` implements `FromSql`. An `Option<T>` represents a
504+ /// nullable Postgres value.
463505pub trait FromSql : Sized {
464506 /// Creates a new value of this type from a `Read` of Postgres data.
465507 ///
@@ -619,6 +661,50 @@ pub enum IsNull {
619661}
620662
621663/// A trait for types that can be converted into Postgres values.
664+ ///
665+ /// # Types
666+ ///
667+ /// The following implementations are provided by this crate, along with the
668+ /// corresponding Postgres types:
669+ ///
670+ /// | Rust type | Postgres type(s) |
671+ /// |---------------------------------------------|--------------------------------|
672+ /// | bool | BOOL |
673+ /// | i8 | "char" |
674+ /// | i16 | SMALLINT, SMALLSERIAL |
675+ /// | i32 | INT, SERIAL |
676+ /// | u32 | OID |
677+ /// | i64 | BIGINT, BIGSERIAL |
678+ /// | f32 | REAL |
679+ /// | f64 | DOUBLE PRECISION |
680+ /// | String | VARCHAR, CHAR(n), TEXT, CITEXT |
681+ /// | &str | VARCHAR, CHAR(n), TEXT, CITEXT |
682+ /// | Vec<u8> | BYTEA |
683+ /// | &[u8] | BYTEA |
684+ /// | HashMap<String, Option<String>> | HSTORE |
685+ ///
686+ /// In addition, some implementations are provided for types in third party
687+ /// crates. These are disabled by default; to opt into one of these
688+ /// implementations, activate the cargo feature corresponding to the crate's
689+ /// name. For example, the `serde` feature enables the implementation for the
690+ /// `serde::json::Value` type.
691+ ///
692+ /// | Rust type | Postgres type(s) |
693+ /// |-----------------------------|-------------------------------------|
694+ /// | serialize::json::Json | JSON, JSONB |
695+ /// | serde::json::Value | JSON, JSONB |
696+ /// | time::Timespec | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
697+ /// | chrono::NaiveDateTime | TIMESTAMP |
698+ /// | chrono::DateTime<UTC> | TIMESTAMP WITH TIME ZONE |
699+ /// | chrono::NaiveDate | DATE |
700+ /// | chrono::NaiveTime | TIME |
701+ /// | uuid::Uuid | UUID |
702+ ///
703+ /// # Nullability
704+ ///
705+ /// In addition to the types listed above, `ToSql` is implemented for
706+ /// `Option<T>` where `T` implements `ToSql`. An `Option<T>` represents a
707+ /// nullable Postgres value.
622708pub trait ToSql : fmt:: Debug {
623709 /// Converts the value of `self` into the binary format of the specified
624710 /// Postgres `Type`, writing it to `out`.
0 commit comments