Derive Macro FromExpr

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

Use in combination with #[rust_query(From = Thing)] to specify which tables this struct should implement FromExpr for.

The implementation of FromExpr will initialize every field from the column with the corresponding name. It is also possible to change the type of each field as long as the new field type implements FromExpr.

#[schema(Example)]
pub mod vN {
    pub struct User {
        pub name: String,
        pub score: i64,
        pub best_game: Option<Game>,
    }
    pub struct Game;
}

#[derive(FromExpr)]
#[rust_query(From = v0::User)]
struct MyUserFields {
    name: String,
    best_game: Option<TableRow<v0::Game>>,
}