Skip to main content

Module admin_form_bridge

Module admin_form_bridge 

Source
Expand description

AdminUiModel → Form bridge + model registry.

Lifts an admin-level metadata description (column data types, relations, options) into a FormConfig the existing form engine already knows how to render. The mapping is purely declarative and deterministic: same input → same output, every time.

The trait + struct here are deliberately named AdminUiModel / AdminUiField (not AdminModel / AdminField). The framework’s existing admin layer in crate::admin already owns the unsuffixed names with a different shape; the Ui suffix keeps the two vocabularies unambiguous in any glob import.

As of this step the trait uses &self methods (object-safe) so an AdminRegistry can store Box<dyn AdminUiModel> and the /admin-new/<slug> route can pick a model by URL slug.

Structs§

AdminRegistry
Slug → factory mapping for the /admin-new/<slug> dispatcher.
AdminUiField

Enums§

AdminDataType
Storage / semantic data type for a column. Translated into a form FieldType by form_from_admin_ui_model.
FilterType
How a filter input should render and how SQL should query it. Resolved from AdminUiField via resolve_filter_type.

Traits§

AdminUiModel
A model that can describe its admin-UI shape (display name + table mapping + column list + searchable / sortable / filterable / status semantics).

Functions§

form_from_admin_ui_model
Build a FormConfig from an AdminUiModel impl. The drawer title becomes "Edit <model_name>"; subtitle is empty (the AdminUiModel contract has no subtitle slot today).
resolve_filter_type
Decide which control + SQL operator a filter on field should use. Pure function — does not look at any data, only metadata.

Type Aliases§

ModelFactory
Boxed factory: any Fn (closure or fn pointer) that yields a fresh Box<dyn AdminUiModel> and is safe to share across the async runtime.