hyperdb_api_core/protocol/message/mod.rs
1// Copyright (c) 2026, Salesforce, Inc. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4//! `PostgreSQL` wire protocol message framing and parsing.
5//!
6//! This module implements the `PostgreSQL` v3 wire protocol's message format.
7//! All structural fields (message tags, lengths, column counts, OIDs, format
8//! codes) use **`BigEndian`** (network byte order), exactly per the `PostgreSQL`
9//! specification. The *data payloads* inside `DataRow` and COPY messages use
10//! `LittleEndian` (`HyperBinary`) -- see [`crate::protocol::copy`] and [`crate::types`].
11//!
12//! # Message Format
13//!
14//! ```text
15//! ┌─────────┬─────────────────┬─────────────────────────────┐
16//! │ Tag (1) │ Length (4, BE) │ Payload (variable) │
17//! └─────────┴─────────────────┴─────────────────────────────┘
18//! ```
19//!
20//! - **Tag**: 1-byte identifier (e.g. `b'Q'` for Query, `b'D'` for `DataRow`).
21//! The startup message is the sole exception -- it has no tag.
22//! - **Length**: 4-byte `BigEndian` `u32`, includes itself but *not* the tag.
23//! - **Payload**: Tag-specific; see [`frontend`] and [`backend`] for details.
24//!
25//! # Sub-modules
26//!
27//! - [`frontend`] -- Messages sent from the client to the server.
28//! - [`backend`] -- Messages sent from the server to the client.
29
30pub mod backend;
31pub mod frontend;
32
33pub use backend::Message;