qail_pg/lib.rs
1//! # QAIL PostgreSQL Driver
2//!
3//! **The world's first AST-native PostgreSQL driver.**
4//!
5//! No SQL strings. No ORM. Direct wire protocol encoding from typed AST.
6//!
7//! ## Performance
8//!
9//! - **Sequential:** 33K queries/sec (1.3x faster than tokio-postgres)
10//! - **Pipelined:** 347K queries/sec (12.8x faster than tokio-postgres)
11//!
12//! ## Architecture
13//!
14//! ```text
15//! QailCmd (AST) → PgEncoder → BytesMut → TCP → PostgreSQL
16//! ```
17//!
18//! ### Layer 2: Protocol (Pure, Sync)
19//! - `PgEncoder` - Compiles QailCmd directly to wire protocol bytes
20//! - No async, no I/O, no tokio, no SQL string generation
21//! - Input: AST → Output: BytesMut
22//!
23//! ### Layer 3: Driver (Async I/O)
24//! - `PgConnection` - TCP/TLS/Unix socket networking
25//! - Production-ready connection pooling (`PgPool`)
26//! - Prepared statement caching
27//! - Wire-level pipelining for batch operations
28//!
29//! ## Features
30//!
31//! - **TLS/SSL** support via rustls
32//! - **Connection pooling** with health checks
33//! - **Wire-level pipelining** for 10x+ throughput
34//! - **Prepared statement caching** with auto-hashing
35//! - **Full type system** (UUID, JSON, Date/Time, Numeric, Arrays)
36//!
37//! ## Example
38//!
39//! ```ignore
40//! use qail_core::ast::QailCmd;
41//! use qail_pg::PgDriver;
42//!
43//! // Build query as typed AST
44//! let cmd = QailCmd::get("users")
45//! .column("id")
46//! .column("email")
47//! .filter("active", Operator::Eq, true);
48//!
49//! // Execute (AST → wire bytes → PostgreSQL → rows)
50//! let mut driver = PgDriver::connect("localhost", 5432, "user", "db").await?;
51//! let rows = driver.fetch_all(&cmd).await?;
52//! ```
53
54pub mod driver;
55pub mod protocol;
56pub mod types;
57
58pub use driver::{
59 PgConnection, PgDriver, PgDriverBuilder, PgError, PgPool, PgResult, PgRow, PoolConfig, PoolStats,
60 PooledConnection,
61};
62pub use protocol::PgEncoder;
63pub use types::{Date, FromPg, Json, Numeric, Time, Timestamp, ToPg, TypeError, Uuid};