Skip to main content

Crate rustio_admin_macros

Crate rustio_admin_macros 

Source
Expand description

Procedural macros for rustio-admin.

#[derive(RustioAdmin)]. Given a user-written struct, the derive emits two impls from the fields it already parses:

  • impl AdminModelADMIN_NAME, DISPLAY_NAME, SINGULAR_NAME, FIELDS, and the row/form/update helpers.
  • impl ::rustio_admin::orm::ModelTABLE, COLUMNS, INSERT_COLUMNS, id, from_row, insert_values. This used to be hand-written in every model file (and had to be kept in sync with the struct by hand); the derive now generates it from the same field walk, so the struct is the single source of truth.

Struct-level escape hatches for the rare cases the field walk can’t infer: #[rustio(table = "…")] when the SQL table name differs from the auto slug (e.g. Addressaddresses), and #[rustio(extra_columns = ["…"])] for generated/virtual columns that are not struct fields (e.g. a Postgres tsvector) but must be SELECT-safe and full-text-search eligible.

The macro deliberately stays dumb: all runtime behaviour lives in rustio_admin. Keeping the macro small makes it easier to debug — if something feels wrong, read the generated code with cargo expand.

Derive Macros§

RustioAdmin