Skip to content

Commit edb990d

Browse files
committed
Document type support on ToSql and FromSql
This also lets us turn back on all of the features in doc builds
1 parent 9d99ea3 commit edb990d

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-2
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ before_script:
1010
script:
1111
- cargo test
1212
- cargo test --features "uuid rustc-serialize time unix_socket serde chrono openssl"
13-
- cargo doc --no-deps --features "unix_socket openssl"
13+
- cargo doc --no-deps --features "unix_socket openssl rustc-serialize time unix_socket serde chrono openssl"
1414
after_success:
15-
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $TRAVIS_RUST_VERSION == "nightly" && ./.travis/update_docs.sh
15+
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $TRAVIS_RUST_VERSION == "stable" && ./.travis/update_docs.sh
1616
env:
1717
global:
1818
secure: cZEcWfKI7Pml5og9o1zBMYhbj20Pa22kYVDTDEHqvOoe0kq1cnB5sTH7P0FUgiPq2Ax4B8eQIaC30yvFJ02R7kmTys4aQD98NyCyzdO+dqYi93C9PFYGhl/DKsb4iZ2VP+8LffYSwRGsNSzE9Fj9SFRMIOjHN+UfaVHXaUVjE7Y=

src/types/mod.rs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
463505
pub 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&lt;u8&gt; | BYTEA |
683+
/// | &[u8] | BYTEA |
684+
/// | HashMap&lt;String, Option&lt;String&gt;&gt; | 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&lt;UTC&gt; | 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.
622708
pub 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

Comments
 (0)