Expand description
Minimal async PostgreSQL wire protocol v3 client.
pg-wired is the lowest-level crate in the resolute workspace. It speaks
the PostgreSQL frontend/backend protocol directly over a tokio socket,
with no SQL parsing, no type system, and no high-level query API. If you
want a typed, derive-driven query layer, use the resolute crate instead;
this crate is the foundation it builds on.
§Protocol features
- Startup, authentication. Cleartext, MD5, and SCRAM-SHA-256 (including channel binding when the connection is TLS-wrapped).
- Extended query protocol.
Parse/Bind/Describe/Execute/Syncwith statement caching at the connection layer. - Pipelining. Multiple round trips fused into a single write via
PgPipeline, with FIFO response matching. - Streaming. Backpressure-aware row streaming for large result sets.
COPYin / out. Both CSV and binary formats.LISTEN/NOTIFY. Bounded notification channel with a dropped- notification counter.- Cancellation. Out-of-band cancel via
CancelTokenusing the server-issued backend key. - TLS. Optional, gated behind the
tlsfeature; usesrustls.
§Where to start
AsyncConnis the main entry point: a single PostgreSQL connection wrapped around the protocol state machine.AsyncPoolis a thin pool overAsyncConn.PgPipelinebatches multiple operations into one round trip.tls::TlsModeselects between plaintext and TLS connections.
§Stability
The public surface is intended to be stable, but pg-wired is primarily
consumed by resolute and its sibling crates. Most application code should
prefer the typed resolute surface.
Re-exports§
pub use async_conn::AsyncConn;pub use async_conn::PipelineResponse;pub use async_conn::ResponseCollector;pub use async_pool::AsyncPool;pub use cancel::CancelToken;pub use connection::WireConn;pub use error::PgWireError;pub use pipeline::PgPipeline;pub use tls::TlsConfig;pub use tls::TlsMode;
Modules§
- async_
conn - Async split sender/receiver connection. Inspired by hsqlx’s PgWire.Async architecture.
- async_
pool - Pool of AsyncConns for spreading load across multiple PostgreSQL backends.
- cancel
- Query cancellation via CancelRequest.
- connection
- Synchronous-style PostgreSQL connection driving the v3 wire protocol on
a single owned
tokio::net::TcpStream. Usecrate::AsyncConnfor the shared, multi-task connection wrapper most callers want. - error
- Error type for the
pg-wiredcrate. - pipeline
- Pipelined query execution: fuse
Parse/Bind/Execute/Syncfor multiple statements into onewrite()and oneflush(). Reuses prepared statements via an LRU statement cache. - tls
- TLS support for PostgreSQL wire connections.
Structs§
Enums§
- Format
Code - Wire format codes.
Type Aliases§
- Oid
- PostgreSQL OID type.