sqlmodel_postgres/lib.rs
1//! PostgreSQL driver for SQLModel Rust.
2//!
3//! `sqlmodel-postgres` is the **Postgres driver** for the SQLModel ecosystem. It
4//! implements the PostgreSQL wire protocol from scratch using asupersync's TCP
5//! primitives and exposes a `Connection` implementation for query execution.
6//!
7//! # Role In The Architecture
8//!
9//! - Implements `sqlmodel-core::Connection` for Postgres
10//! - Provides authentication, protocol framing, and type conversions
11//! - Powers `sqlmodel-query` execution and `sqlmodel-session` persistence
12//!
13//! This crate implements the PostgreSQL wire protocol from scratch using
14//! asupersync's TCP primitives. It provides:
15//!
16//! - Message framing and parsing
17//! - Authentication (cleartext, MD5, SCRAM-SHA-256)
18//! - Simple and extended query protocols
19//! - Connection management with state machine
20//! - Type conversion between Rust and PostgreSQL types
21//!
22//! # Type System
23//!
24//! The `types` module provides comprehensive type mapping between PostgreSQL
25//! and Rust types, including:
26//!
27//! - OID constants for all built-in types
28//! - Text and binary encoding/decoding
29//! - Type registry for runtime type lookup
30//!
31//! # Example
32//!
33//! ```rust,ignore
34//! use sqlmodel_postgres::{PgConfig, PgConnection};
35//!
36//! let config = PgConfig::new()
37//! .host("localhost")
38//! .port(5432)
39//! .user("postgres")
40//! .database("mydb");
41//!
42//! let conn = PgConnection::connect(config)?;
43//! ```
44
45pub mod async_connection;
46pub mod auth;
47pub mod config;
48pub mod connection;
49pub mod protocol;
50pub mod tls;
51pub mod types;
52
53pub use async_connection::{PgAsyncConnection, SharedPgConnection, SharedPgTransaction};
54pub use config::{PgConfig, SslMode};
55pub use connection::{ConnectionState, PgConnection, TransactionStatusState};
56pub use types::{Format, TypeCategory, TypeInfo, TypeRegistry};
57
58// Console integration (feature-gated)
59#[cfg(feature = "console")]
60pub use connection::ConnectionStage;
61#[cfg(feature = "console")]
62pub use sqlmodel_console::ConsoleAware;