Skip to main content

TableValueRow

Derive Macro TableValueRow 

Source
#[derive(TableValueRow)]
{
    // Attributes available to this derive:
    #[colname]
}
Expand description

Generates a trivial implementation of the TableValueRow trait.

§Applications

Apply to structs that represent rows of a table-valued parameter.

§Example

ⓘ
#[derive(TableValueRow)]
pub struct SomeGeoList {
  #[colname = "SomeID"]
  pub id: i32,
  #[colname = "LastSyncIPGeoLat"]
  pub lat: Numeric,
  #[colname = "LastSyncIPGeoLong"]
  pub lon: Numeric,
}

§Supported field types

Each field is bound with SqlTableDataRow::add_field(self.<field>), so the field type must implement IntoSql by value. That covers the Copy scalar/marker types (i32, i64, bool, f64, Numeric, Uuid, …) and borrowed strings/bytes (&str, &[u8]). Owned, non-Copy columns such as String or Vec<u8> cannot be moved out of &self; model those columns as &str / &[u8] (with a struct lifetime) instead.