Expand description
Admin Intelligence Layer — 0.7.0.
Pure helpers that turn schema + context into user-facing hints:
the form-field label beside a personnummer input, the masked
display of a sensitive value on a list page, the filter dropdown
inferred from a status column, the “Interpreted as ID” badge on a
numeric search. Nothing in this module touches the filesystem, the
database, or produces HTML — it returns structured data that the
admin renderer consumes.
§Principles
- Inference, not configuration. Rules are derived from
(field name, field type, nullability) + ContextConfig. No per-project hooks. - Conservative sensitivity. Under GDPR / country rules, the layer marks a field as sensitive up, never down. A project without context gets 0.6.x behaviour.
- Deterministic. Same inputs → same outputs. No ordering surprises, no random masking length.
§Public API
classify_field— labels a field by role (Id,Email,Personnummer, …). Every downstream renderer branches on this enum.field_ui_metadata— packages the label, placeholder, hint, and sensitivity marker a form needs to render one input.infer_filters— walks a model’s fields and decides which filters make sense on its list page.classify_search— inspects a search query and tells the list handler what the user probably meant (NumericId,Email,Personnummer,Text).mask_pii— deterministic string masker used to hide personal data by default on list views.
Structs§
- FieldUI
- Everything a form / list renderer needs to present one field to a human. All strings are plain text (no HTML) — the caller escapes before emitting.
- Filter
Def - One filter the list page should show for a model. Produced by
infer_filters.
Enums§
- Field
Role - The role a field plays in the admin UI. One field maps to exactly
one role; the ordering of branches in
classify_fieldresolves overlaps (e.g. anemailcolumn isFieldRole::Email, notFieldRole::PlainText). - Filter
Kind - What shape of filter the admin list page should render for a given field. Each variant maps to a concrete HTML control.
- Search
Intent - What the user probably typed into the list-page search box. Letting the handler branch on this gives cleaner narrow-match behaviour than “grep every String field”.
Functions§
- classify_
field - Assign a
FieldRoleto one field, taking context into account. - classify_
search - Guess what the user meant by the text in the list-page search box. Order of tries: numeric → email → personnummer → text.
- classify_
search_ for_ field - 0.8.0 — variant of
classify_searchthat knows the field is a relation. When the query parses as a non-negative integer, emitsSearchIntent::RelationIdcarrying the target model; otherwise falls through toclassify_searchfor the usual shape-based routing. Called by the admin search handler when the user is searching a specific FK column. - context_
global - Process-global cache for the project’s
rustio.context.json. - field_
ui_ metadata - Package a field’s display metadata for the admin form / list renderers. All strings are plain text — escape before emitting.
- field_
ui_ metadata_ with_ relation - 0.8.0 — like
field_ui_metadatabut relation-aware. Pass the singular display name of the target model (e.g."Applicant") when the schema records a relation for this field; the returnedFieldUIthen carriesrelation_labeland a form hint of the form “Foreign key to Applicant”. PassingNoneis equivalent to callingfield_ui_metadata. - format_
relation_ cell - Render “Target #42” for a foreign-key cell on a list view. Falls
back to the raw id when the caller doesn’t have a target name.
Kept as a free function so the admin list renderer doesn’t have to
reach into
FieldUIdirectly for the common case. - infer_
filters - Infer the filter controls for a model’s list page from its fields
plus active context. Order follows the order of
fields; every filter references a field that actually exists on the model. - infer_
filters_ with_ relations - 0.8.0 — like
infer_filtersbut invokesrelation_target_offor each field to detect relation columns. If the callback returnsSome(target), the filter is emitted asFilterKind::RelationSelectinstead of the numeric-exact fallback. - mask_
pii - Produce a masked display string for a sensitive value. Keeps the
first few characters so a reviewer can tell which row they’re
looking at, replaces the rest with
•. Length of the output matches the input so the layout doesn’t jump when a user toggles visibility.