Admin code generation
`runique start` behaviour
runique start is not a background watcher: it's a sequential one-shot generation, followed by a blocking launch of the application.
src/admin.rsis read once- The
admin! { ... }macro is parsed viasyn, producingResourceDefstructures - The contents of
src/admins/are rewritten in place (files are truncated and rewritten — the folder is never deleted beforehand) cargo fmt --allrunscargo run --releaseruns, blocking, in the same process
There is no continuous file watching and no debounce: an earlier implementation based on a separate thread was removed because it caused a race condition. To regenerate after a change, run runique start again.
Generated structure
src/admins/
├── README.md ← warning: do not edit manually
├── mod.rs ← exposes `routes` and `admin_state`
└── admin.rs ← main file: DynForm wrappers + admin_register()
admin.rs
Contains for each resource declared in admin!:
- A
DynFormwrapper around the concrete Runique form - The closures
list_fn,get_fn,create_fn,update_fn,delete_fn,count_fn,partial_update_fn(always generated, used for bulk edit/group actions) - If
list_filteris declared: afilter_fnclosure per field, loading distinct values from the database (up to 10 by default) - The
admin_register()function that builds theHashMap<String, ResourceEntry>loaded at boot
mod.rs
Re-exports routes and admin_state from admin.
The trade-off: automatic overwriting
Every run of runique start rewrites the contents of src/admins/ (files truncated and regenerated, never deleted beforehand).
Any manual modifications inside this folder will be lost on the next runique start.
When to switch to `cargo run`
If manual changes to the generated code are needed (specific business logic, custom handler), you must stop runique start and switch to a standard workflow:
cargo run
In this mode, runique start never runs, so src/admins/ is never rewritten. Changes persist.
The
README.mdgenerated insidesrc/admins/reminds you of this behaviour directly in the repository.
Related sections
| Section | Description |
|---|---|
| CLI | How runique start works |
Macro admin! | Declaring administrable resources |