#[derive(FromRow)]
{
// Attributes available to this derive:
#[mssql]
}
Expand description
Derive macro for implementing FromRow trait.
This macro generates code to convert a database row into a struct.
§Attributes
§Field Attributes
#[mssql(rename = "column_name")]- Map field to a different column name#[mssql(skip)]- Skip this field (must have a Default implementation)#[mssql(default)]- Use Default if column is NULL or missing#[mssql(flatten)]- Flatten a nested struct implementing FromRow
§Struct Attributes
#[mssql(rename_all = "snake_case")]- Apply naming convention to all fields
§Example
ⓘ
#[derive(FromRow)]
#[mssql(rename_all = "PascalCase")]
struct User {
id: i32,
#[mssql(rename = "UserName")]
name: String,
#[mssql(default)]
email: Option<String>,
#[mssql(skip)]
computed: String,
}