Skip to main content

FromRow

Derive Macro FromRow 

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

Derive FromRow for structs with named fields.

§Field attributes

  • #[from_row(rename = "col")] — use a different column name
  • #[from_row(skip)] — skip the field, use Default::default()
  • #[from_row(default)] — use Default::default() if column is NULL or missing
  • #[from_row(json)] — deserialize a JSON/JSONB column via serde
  • #[from_row(try_from = "SourceType")] — decode as SourceType, then TryFrom convert
  • #[from_row(flatten)] — call FromRow::from_row on a nested struct