Skip to main content

FromRow

Derive Macro FromRow 

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

Derive macro: auto-generates an sz_orm_core::queryable::FromRow trait impl.

Deserializes from a HashMap<String, Value> by column name into a struct instance. Differs from FromQueryResult in that the error type is QueryError (includes column info), suitable for low-level scenarios that need precise error localization.

§Supported attributes

  • #[column(name = "...")] — overrides the column name mapping (defaults to the field name)

§Example

use sz_orm_macros::FromRow;

#[derive(FromRow)]
struct User {
    id: i64,
    name: String,
    #[column(name = "user_email")]
    email: Option<String>,
}