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.

§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 endian-aware types (e.g., I64LE instead of i64)

§Example

use zerocopy::little_endian::{I64 as I64LE, I32 as I32LE};
use zero_mysql::ref_row::RefFromRow;

#[derive(RefFromRow)]
#[repr(C, packed)]
struct UserStats {
    user_id: I64LE,
    login_count: I32LE,
}

Traits§

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

Type Aliases§

I16LE
A 16-bit signed integer stored in little-endian byte order.
I32LE
A 32-bit signed integer stored in little-endian byte order.
I64LE
A 64-bit signed integer stored in little-endian byte order.
U16LE
A 16-bit unsigned integer stored in little-endian byte order.
U32LE
A 32-bit unsigned integer stored in little-endian byte order.
U64LE
A 64-bit unsigned integer stored in little-endian byte order.