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;
45mod instrumentation;
46pub mod notify;
47pub mod pipeline;
48pub mod pool;
49pub mod portal;
50pub mod protocol;
51pub mod row;
52pub mod statement;
53pub mod stream;
54pub mod tls;
55mod tracing_adapter;
56pub mod transaction;
57pub mod types;
58
59// ── Public re-exports ────────────────────────────────
60
61pub use advisory_lock::{PgAdvisoryLock, PgAdvisoryLockGuard};
62pub use cache::{CacheMetrics, StatementCache};
63pub use cancel::CancelToken;
64pub use config::{ChannelBinding, Config, LoadBalanceHosts, SslMode, TargetSessionAttrs};
65pub use connection::Connection;
66pub use copy::binary::{BinaryCopyDecoder, BinaryCopyEncoder};
67pub use copy::text::{TextCopyDecoder, TextCopyEncoder};
68pub use error::{Error, Result};
69pub use generic_client::GenericClient;
70pub use instrumentation::{
71    AcquireOutcome, DisconnectReason, Event, Instrumentation, Outcome, RollbackReason, StmtRef,
72};
73pub use notify::Notification;
74pub use pool::{Pool, PoolMetrics, PooledConnection};
75pub use portal::Portal;
76pub use row::{CommandResult, Row, RowDescription, SimpleQueryMessage, SimpleQueryRow};
77pub use statement::Statement;
78pub use stream::RowStream;
79pub use tracing_adapter::TracingInstrumentation;
80pub use transaction::{IsolationLevel, TransactionConfig};
81pub use types::{FromSql, Oid, ToSql};
82
83#[cfg(feature = "with-serde-json")]
84pub use types::json::Json;
85
86// Re-export derive macros when the `derive` feature is enabled
87#[cfg(feature = "derive")]
88pub use sentinel_derive::{FromRow, FromSql, ToSql};