Module row

Module row 

Source
Expand description

Zero-copy row deserialization traits and utilities.

This module provides traits for efficient row deserialization that minimizes memory allocations by borrowing data directly from the database row.

§Zero-Copy Deserialization

The FromRowRef trait enables zero-copy deserialization for types that can borrow string data directly from the row:

use prax_query::row::{FromRowRef, RowRef};

struct UserRef<'a> {
    id: i32,
    email: &'a str,  // Borrowed from row
    name: Option<&'a str>,
}

impl<'a> FromRowRef<'a> for UserRef<'a> {
    fn from_row_ref(row: &'a impl RowRef) -> Result<Self, RowError> {
        Ok(Self {
            id: row.get("id")?,
            email: row.get_str("email")?,
            name: row.get_str_opt("name")?,
        })
    }
}

§Performance

Zero-copy deserialization can significantly reduce allocations:

  • String fields borrow directly from row buffer (no allocation)
  • Integer/float fields are copied (no difference)
  • Optional fields return Option<&'a str> instead of Option<String>

Structs§

RowRefIter
A row iterator that yields zero-copy deserialized values.

Enums§

RowData
A collected result that can either borrow or own data.
RowError
Error type for row deserialization.

Traits§

FromColumn
Trait for types that can be extracted from a column.
FromRow
Trait for types that can be deserialized from a row (owning).
FromRowRef
Trait for types that can be deserialized from a row reference (zero-copy).
RowRef
A database row that supports zero-copy access.