Skip to main content

Module ref_row

Module ref_row 

Source
Expand description

Zero-copy row decoding for fixed-size types.

This module provides traits and types for zero-copy decoding of database rows where all fields have fixed wire sizes. This is useful for high-performance scenarios where avoiding allocations is critical.

§PostgreSQL Wire Format

PostgreSQL’s binary protocol includes a 4-byte length prefix before each column value. To enable zero-copy struct casting, use LengthPrefixed<T> wrapper which accounts for this prefix in its layout.

§Requirements

  • All struct fields must implement FixedWireSize
  • All columns must be NOT NULL (no Option<T> support)
  • Struct must use #[repr(C, packed)] for predictable layout
  • Fields must use LengthPrefixed<T> with big-endian types

§Compile-time Safety

The derive macro enforces that all fields implement FixedWireSize at compile time. Variable-length types like String or Vec<T> will cause a compilation error.

Structs§

LengthPrefixed
A length-prefixed value matching PostgreSQL’s binary wire format.

Traits§

FixedWireSize
Marker trait for types with a fixed wire size in PostgreSQL binary protocol.
RefFromRow
Trait for zero-copy decoding of a row into a fixed-size struct.

Type Aliases§

I16BE
A 16-bit signed integer stored in big-endian byte order.
I32BE
A 32-bit signed integer stored in big-endian byte order.
I64BE
A 64-bit signed integer stored in big-endian byte order.
U16BE
A 16-bit unsigned integer stored in big-endian byte order.
U32BE
A 32-bit unsigned integer stored in big-endian byte order.
U64BE
A 64-bit unsigned integer stored in big-endian byte order.