Expand description
Dynamic AdminEntry construction — 0.7.3.
The compile-time AdminEntry list is baked by
#[derive(RustioAdmin)] and drives route registration — there
is no way to register a GET/POST pair for a struct the binary
doesn’t know about. But for everything that just reads the
model shape (the dashboard alerts, the suggestion engine, the
schema diff on the review page), the schema on disk is a better
source of truth than the compiled &'static [AdminField] slice.
This module turns that observation into a concrete type. A
DynamicAdminEntry is the same conceptual shape as an
AdminEntry but with owned String names and an owned
Vec<DynamicAdminField>. Renderers that currently iterate
compile-time entries can iterate dynamic ones instead; the only
thing they give up is &'static identity.
§Safety
field_type_from_stris total: an unknown string never panics, it falls back toFieldType::String(which the renderer shows as a plain-text input). The CHANGELOG bump rule means the planner + schema layers would catch unknown types much earlier, but the fallback here is the defence in depth.entries_effectiveis deterministic: when the cache is warm, order followsschema.models; when it’s cold, order follows the compile-time slice. Neither path allocates randomness.
§What this module does NOT do
- It does not register routes. Route registration still needs a
real
T: AdminModelbecauseitem.field_display(name)is trait-bound. - It does not mutate the schema cache. Reads only.
Structs§
- Dynamic
Admin Entry - Same shape as
AdminEntrybut with owned strings, so a schema re-read can rebuild one without touching the compile-time slice. - Dynamic
Admin Field - Same shape as
AdminFieldbut owned. Derived either from a&'static AdminFieldor from acrate::schema::SchemaField.
Functions§
- build_
admin_ entries - Build a
Vec<DynamicAdminEntry>from the schema on disk. Every model’s fields are projected from schema fields; unknown type strings fall back toFieldType::String(seefield_type_from_str). Order followsschema.models. - entries_
effective - Single source of truth for rendering-side admin entries.
- field_
type_ from_ str - Parse a schema-level type name (
"i32","DateTime", …) back into aFieldType. Unknown strings fall through toFieldType::Stringso the renderer shows a plain-text input instead of panicking — the 0.7.3 “render as PlainText” rule.