Skip to main content

sentinel_driver/
lib.rs

1//! # sentinel-driver
2//!
3//! High-performance PostgreSQL wire protocol driver for Rust.
4//! Foundation layer for Sentinel ORM.
5//!
6//! ## Features
7//!
8//! - PG-only — every PostgreSQL feature is first-class
9//! - Single-task architecture — no channel overhead
10//! - Pipeline mode — automatic query batching (PG 14+)
11//! - COPY protocol — bulk insert 10-50x faster than INSERT
12//! - LISTEN/NOTIFY — first-class realtime notifications
13//! - SCRAM-SHA-256 with correct SASLprep
14//! - Zero-copy parsing for large column values
15//! - Two-tier prepared statement cache
16//! - Connection pool with <0.5μs checkout
17//!
18//! ## Quick Start
19//!
20//! ```rust,no_run
21//! use sentinel_driver::{Config, Connection};
22//!
23//! # async fn example() -> sentinel_driver::Result<()> {
24//! let config = Config::parse("postgres://user:pass@localhost/mydb")?;
25//! let mut conn = Connection::connect(config).await?;
26//!
27//! let rows = conn.query("SELECT id, name FROM users WHERE active = $1", &[&true]).await?;
28//! for row in &rows {
29//!     let id: i32 = row.get(0);
30//!     let name: String = row.get(1);
31//! }
32//! # Ok(())
33//! # }
34//! ```
35
36pub mod advisory_lock;
37pub mod auth;
38pub mod cache;
39pub mod cancel;
40pub mod config;
41pub mod connection;
42pub mod copy;
43pub mod error;
44pub mod generic_client;
45pub mod notify;
46pub mod observability;
47pub mod pipeline;
48pub mod pool;
49pub mod portal;
50pub mod protocol;
51pub mod row;
52pub mod statement;
53pub mod stream;
54pub mod tls;
55pub mod transaction;
56pub mod types;
57
58// ── Public re-exports ────────────────────────────────
59
60pub use advisory_lock::{PgAdvisoryLock, PgAdvisoryLockGuard};
61pub use cache::{CacheMetrics, StatementCache};
62pub use cancel::CancelToken;
63pub use config::{ChannelBinding, Config, LoadBalanceHosts, SslMode, TargetSessionAttrs};
64pub use connection::Connection;
65pub use copy::binary::{BinaryCopyDecoder, BinaryCopyEncoder};
66pub use copy::text::{TextCopyDecoder, TextCopyEncoder};
67pub use error::{Error, Result};
68pub use generic_client::GenericClient;
69pub use notify::Notification;
70pub use observability::{ObservabilityConfig, QueryMetrics, QueryMetricsCallback};
71pub use pool::{Pool, PoolMetrics, PooledConnection};
72pub use portal::Portal;
73pub use row::{CommandResult, Row, RowDescription, SimpleQueryMessage, SimpleQueryRow};
74pub use statement::Statement;
75pub use stream::RowStream;
76pub use transaction::{IsolationLevel, TransactionConfig};
77pub use types::{FromSql, Oid, ToSql};
78
79#[cfg(feature = "with-serde-json")]
80pub use types::json::Json;
81
82// Re-export derive macros when the `derive` feature is enabled
83#[cfg(feature = "derive")]
84pub use sentinel_derive::{FromRow, FromSql, ToSql};