pgwire_replication/protocol/mod.rs
1//! PostgreSQL wire protocol implementation.
2//!
3//! This module provides low-level primitives for:
4//! - Reading and writing PostgreSQL frontend/backend messages ([`framing`])
5//! - Parsing authentication and error responses ([`messages`])
6//! - Handling streaming replication protocol messages ([`replication`])
7//!
8//! # Wire Protocol Overview
9//!
10//! PostgreSQL uses a message-based protocol where each message consists of:
11//! - 1 byte: message type tag
12//! - 4 bytes: message length (including these 4 bytes)
13//! - N bytes: message payload
14//!
15//! Exception: Startup and SSL request messages omit the type tag.
16//!
17//! # Replication Protocol
18//!
19//! During logical replication, the server sends CopyData messages containing
20//! either `XLogData` (WAL changes) or `KeepAlive` (heartbeats). The client
21//! responds with `StandbyStatusUpdate` messages to report replay progress.
22
23pub mod framing;
24pub mod messages;
25pub mod replication;
26
27pub use framing::BackendMessage;
28pub use messages::{parse_auth_request, parse_error_response, ErrorFields};
29pub use replication::{
30 encode_standby_status_update, parse_copy_data, pg_to_unix_timestamp, unix_to_pg_timestamp,
31 ReplicationCopyData, PG_EPOCH_MICROS,
32};