postgres/
lib.rs

1//! A synchronous client for the PostgreSQL database.
2//!
3//! # Example
4//!
5//! ```no_run
6//! use postgres::{Client, NoTls};
7//!
8//! # fn main() -> Result<(), postgres::Error> {
9//! let mut client = Client::connect("host=localhost user=postgres", NoTls)?;
10//!
11//! client.batch_execute("
12//!     CREATE TABLE person (
13//!         id      SERIAL PRIMARY KEY,
14//!         name    TEXT NOT NULL,
15//!         data    BYTEA
16//!     )
17//! ")?;
18//!
19//! let name = "Ferris";
20//! let data = None::<&[u8]>;
21//! client.execute(
22//!     "INSERT INTO person (name, data) VALUES ($1, $2)",
23//!     &[&name, &data],
24//! )?;
25//!
26//! for row in client.query("SELECT id, name, data FROM person", &[])? {
27//!     let id: i32 = row.get(0);
28//!     let name: &str = row.get(1);
29//!     let data: Option<&[u8]> = row.get(2);
30//!
31//!     println!("found person: {} {} {:?}", id, name, data);
32//! }
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! # Implementation
38//!
39//! This crate is a lightweight wrapper over tokio-postgres. The `postgres::Client` is simply a wrapper around a
40//! `tokio_postgres::Client` along side a tokio `Runtime`. The client simply blocks on the futures provided by the async
41//! client.
42//!
43//! # SSL/TLS support
44//!
45//! TLS support is implemented via external libraries. `Client::connect` and `Config::connect` take a TLS implementation
46//! as an argument. The `NoTls` type in this crate can be used when TLS is not required. Otherwise, the
47//! `postgres-openssl` and `postgres-native-tls` crates provide implementations backed by the `openssl` and `native-tls`
48//! crates, respectively.
49//!
50//! # Features
51//!
52//! The following features can be enabled from `Cargo.toml`:
53//!
54//! | Feature | Description | Extra dependencies | Default |
55//! | ------- | ----------- | ------------------ | ------- |
56//! | `with-bit-vec-0_6` | Enable support for the `bit-vec` crate. | [bit-vec](https://crates.io/crates/bit-vec) 0.6 | no |
57//! | `with-chrono-0_4` | Enable support for the `chrono` crate. | [chrono](https://crates.io/crates/chrono) 0.4 | no |
58//! | `with-eui48-0_4` | Enable support for the 0.4 version of the `eui48` crate. This is deprecated and will be removed. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
59//! | `with-eui48-1` | Enable support for the 1.0 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 1.0 | no |
60//! | `with-geo-types-0_6` | Enable support for the 0.6 version of the `geo-types` crate. | [geo-types](https://crates.io/crates/geo-types/0.6.0) 0.6 | no |
61//! | `with-geo-types-0_7` | Enable support for the 0.7 version of the `geo-types` crate. | [geo-types](https://crates.io/crates/geo-types/0.7.0) 0.7 | no |
62//! | `with-serde_json-1` | Enable support for the `serde_json` crate. | [serde_json](https://crates.io/crates/serde_json) 1.0 | no |
63//! | `with-uuid-0_8` | Enable support for the `uuid` crate. | [uuid](https://crates.io/crates/uuid) 0.8 | no |
64//! | `with-uuid-1` | Enable support for the `uuid` crate. | [uuid](https://crates.io/crates/uuid) 1.0 | no |
65//! | `with-time-0_2` | Enable support for the 0.2 version of the `time` crate. | [time](https://crates.io/crates/time/0.2.0) 0.2 | no |
66//! | `with-time-0_3` | Enable support for the 0.3 version of the `time` crate. | [time](https://crates.io/crates/time/0.3.0) 0.3 | no |
67#![warn(clippy::all, rust_2018_idioms, missing_docs)]
68
69pub use fallible_iterator;
70pub use tokio_postgres::{
71    error, row, tls, types, Column, IsolationLevel, Notification, Portal, SimpleQueryMessage,
72    Socket, Statement, ToStatement,
73};
74
75pub use crate::cancel_token::CancelToken;
76pub use crate::client::*;
77pub use crate::config::Config;
78pub use crate::copy_in_writer::CopyInWriter;
79pub use crate::copy_out_reader::CopyOutReader;
80#[doc(no_inline)]
81pub use crate::error::Error;
82pub use crate::generic_client::GenericClient;
83#[doc(inline)]
84pub use crate::notifications::Notifications;
85#[doc(no_inline)]
86pub use crate::row::{Row, SimpleQueryRow};
87pub use crate::row_iter::RowIter;
88#[doc(no_inline)]
89pub use crate::tls::NoTls;
90pub use crate::transaction::*;
91pub use crate::transaction_builder::TransactionBuilder;
92
93pub mod binary_copy;
94mod cancel_token;
95mod client;
96pub mod config;
97mod connection;
98mod copy_in_writer;
99mod copy_out_reader;
100mod generic_client;
101mod lazy_pin;
102pub mod notifications;
103mod row_iter;
104mod transaction;
105mod transaction_builder;
106
107#[cfg(test)]
108mod test;
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy