Skip to main content

qail_pg/
lib.rs

1//! PostgreSQL driver with AST-native wire encoding.
2//!
3//! **Features:** Zero-alloc encoding, LRU cache (100 max), connection pooling, COPY protocol.
4//!
5//! ```ignore
6//! let mut driver = PgDriver::connect("localhost", 5432, "user", "db").await?;
7//! let rows = driver.fetch_all(&Qail::get("users").limit(10)).await?;
8//! ```
9
10pub mod driver;
11pub mod protocol;
12pub mod types;
13
14pub use driver::{
15    Notification, PgConnection, PgDriver, PgDriverBuilder, PgError, PgPool, PgResult, PgRow, PoolConfig, PoolStats,
16    PooledConnection, QailRow, QueryResult,
17};
18pub use protocol::PgEncoder;
19pub use driver::explain;
20pub use types::{Date, FromPg, Json, Numeric, Time, Timestamp, ToPg, TypeError, Uuid};
21
22/// Generate the RLS SQL string for pipelined execution.
23///
24/// Returns the `BEGIN; SET LOCAL statement_timeout = ...; SELECT set_config(...)`
25/// string that can be passed to `PooledConnection::fetch_all_with_rls()`.
26pub fn rls_sql_with_timeout(ctx: &qail_core::rls::RlsContext, timeout_ms: u32) -> String {
27    driver::rls::context_to_sql_with_timeout(ctx, timeout_ms)
28}