Skip to main content

Module admin

Module admin 

Source
Expand description

Auto-generated CRUD admin backed by crate::orm.

Build an Admin by chaining .model::<T>() calls, then mount it with Admin::register. This attaches list / create / edit / delete routes at /admin/<admin_name> for each model and an index page at /admin listing every registered model.

§UI ownership

The admin HTML shell, layout, forms, tables, auth pages, and error states are framework-owned: there is no hook for a project to replace these templates. Visual customisation — logo mark, project display name, primary/accent colour, density — flows through the design::Design config (loaded from rustio.design.json if present). The public templates/ + static/ directories of a generated project are for public site pages, not for admin overrides.

For a single-model app, register is a convenience wrapper.

Re-exports§

pub use crate::http::FormData;

Modules§

admin_form_bridge
AdminUiModel → Form bridge + model registry.
admin_generator
Config-driven admin model generator.
audit
Admin action log — every create / update / delete driven through the admin writes a row to rustio_admin_actions. The audit trail powers two user-visible surfaces:
auto_form
Auto form generation — derive a FormConfig from a Rust type that implements FormModel, no manual field-by-field wiring.
design
Admin design customisation.
entry_builder
Dynamic AdminEntry construction — 0.7.3.
form
Admin-new form engine.
intelligence
Admin Intelligence Layer — 0.7.0.
layout
Admin page assembler.
persistence
Persistence helpers for the admin engine — basic CREATE + UPDATE.
rbac
Role-based access control for the admin UI (0.10+).
relations
Relation Intelligence Layer — runtime registry.
schema_cache
Process-local schema cache — 0.7.2.
schema_introspect
Database-driven AdminModelConfig generation.
suggestions
Actionable suggestion engine — 0.7.1.
templating
Admin UI template engine.
ui
HTML-escape helper used by Rust code that still concatenates small fragments outside the main minijinja templates (e.g. FK cell links inside list_render, form-field controls inside form_render). Every shell element — topbar, sidebar, page header — is rendered through templates as of 0.10.

Structs§

Admin
Builder that collects admin models and mounts them with a shared /admin index page.
AdminEntry
Metadata about one registered admin model.
AdminField
Metadata about one struct field, generated by #[derive(RustioAdmin)] and consumed by the admin renderer + the schema exporter.
AdminRelation
Compile-time mirror of crate::schema::Relation. Uses &'static str so the whole thing is const-constructible by the #[derive(RustioAdmin)] macro and can live inside the AdminField-typed const FIELDS slice without a runtime allocation.

Enums§

FieldType
The primitive types the admin + schema layers know how to render, validate, and serialise.

Constants§

CSRF_FIELD
Name of the hidden form field that carries the per-session CSRF token.
MAX_FORM_BODY_BYTES
Maximum size of an admin form body.
USER_FIELDS
Fields the built-in User model exposes via the schema. Kept as a const so tests and the schema exporter reference the same source of truth. password_hash is marked editable: false so no future UI layer accidentally surfaces the hash in a form; created_at mirrors the rustio_users.created_at column so the schema doesn’t under-describe the actual table shape.

Traits§

AdminModel

Functions§

parse_datetime_local
Parse the YYYY-MM-DDTHH:MM[:SS] value emitted by the browser’s <input type="datetime-local"> widget into a DateTime<Utc>.
register
Convenience: mount CRUD routes and an /admin index for a single model.
register_from_table
Schema-driven counterpart to register_generated. Reads the table’s columns via PRAGMA table_info, builds an AdminModelConfig from them, and registers it under the derived slug. The table must already exist — this helper does not issue CREATE TABLE.
register_generated
Register a config-driven model under its own slug. The closure captures cfg and clones it on every lookup, so the registry’s Fn factory can build a fresh Box<dyn AdminUiModel> per request without any global state.