1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! # chopin-pg
//!
//! A zero-copy, high-performance PostgreSQL driver designed for the
//! Chopin thread-per-core, Shared-Nothing architecture.
//!
//! ## Features
//! - **Thread-per-core**: Each worker owns its own PG connections.
//! - **Non-blocking I/O**: Socket is set to non-blocking after connect; all
//! reads/writes go through poll-based primitives with configurable timeouts.
//! - **Zero-copy**: Row data is sliced directly from the read buffer.
//! - **SCRAM-SHA-256**: Full authentication support.
//! - **Extended Query Protocol**: Parse/Bind/Execute with implicit caching.
//! - **Transaction support**: Safe closure-based API with auto-rollback.
//! - **COPY protocol**: Both COPY IN (writer) and COPY OUT (reader).
//! - **LISTEN/NOTIFY**: Notification buffering during query processing.
//! - **Rich types**: UUID, Date, Time, Timestamp, Interval, Numeric, INET, Arrays.
//! - **Binary INET/CIDR**: Proper binary encoding/decoding for network types.
//! - **Type-safe queries**: `ToSql`/`FromSql` traits for ergonomic parameter passing.
//! - **Connection pool**: Worker-local pool with RAII `ConnectionGuard`, FIFO idle
//! queue, `try_get()` / `get()` with timeout, and automatic return on drop.
//! - **Error classification**: Transient vs permanent errors for retry logic.
//!
//! ## Quick Start
//! ```ignore
//! use chopin_pg::{PgConfig, PgConnection};
//!
//! let config = PgConfig::new("localhost", 5432, "user", "pass", "mydb");
//! let mut conn = PgConnection::connect(&config)?;
//!
//! // Simple query
//! let rows = conn.query("SELECT $1::int4 + $2::int4", &[&1i32, &2i32])?;
//! let sum: i32 = rows[0].get_typed(0)?;
//!
//! // Transaction with closure
//! conn.transaction(|tx| {
//! tx.execute("INSERT INTO users (name) VALUES ($1)", &[&"Alice"])?;
//! Ok(())
//! })?;
//! ```
//!
//! ## Pool Usage
//! ```ignore
//! use chopin_pg::{PgConfig, PgPool, PgPoolConfig};
//!
//! let config = PgConfig::new("localhost", 5432, "user", "pass", "mydb");
//! let pool_cfg = PgPoolConfig::new().max_size(25).checkout_timeout(Duration::from_secs(3));
//! let mut pool = PgPool::connect_with_config(config, pool_cfg)?;
//!
//! // Get a connection — returned to pool when guard drops
//! let mut guard = pool.get()?;
//! let rows = guard.query("SELECT 1", &[])?;
//! // guard drops → connection returned to idle queue
//! ```
pub use ;
pub use ;
pub use ;
pub use Row;
pub use Statement;
pub use ;