rustango-orm-macros
Proc-macros for the standalone rustango-orm crate — ORM-only carve-out of rustango-macros.
This crate exposes only the three proc-macros the ORM core actually needs:
| Macro | What it does |
|---|---|
#[derive(Model)] |
Populates <T>::SCHEMA, generates inherent methods (insert / save / delete / find / where_* / sum / etc.), and registers the model with the inventory crate. |
#[derive(Form)] |
Validates user input + parses it into a strongly-typed struct. |
embed_migrations! |
Bakes a migrations/ directory's .json files into a &'static [(name, content)] slice at compile time. |
The framework-only derives (Serializer, ViewSet, Q!, #[rustango::main]) live in rustango-macros and are intentionally not re-exported here. Consumers that depend only on rustango-orm-macros literally cannot reach them — that's the carve-out half of issue #143.
Quickstart
[]
= "0.58"
# There is no standalone `rustango-orm` runtime crate — pull in `rustango`:
= { = "0.58", = false, = ["sqlite"] }
use Auto;
use Model;
Why a separate crate?
The orm-extract epic (#149) set out to carve the rustango ORM out of the framework crate, so projects that only want derive-driven models against an existing database could pull in the ORM bits without admin / tenancy / templates / auth.
That epic is closed and the carve-out was deferred — the runtime slice (#144) is closed too, and no rustango-orm crate exists. The blocker is entanglement between m2m and signals/contenttypes, which cannot be split without taking those along.
So this crate is what it is rather than a staging post: a thin re-exporter over rustango-macros, useful if you want to name the ORM macros separately. The proc-macro bodies are not migrating here.
How proc-macro re-export works
Rust's resolver follows pub use paths to find a proc-macro's defining crate. Writing use rustango_orm_macros::Model; resolves to pub use rustango_macros::Model;, walks back to the proc-macro = true crate where the derive is actually defined, and invokes its entry point. Because of this resolution chain, the re-exporter itself doesn't need proc-macro = true — it's a regular [lib] crate.
License
MIT OR Apache-2.0 — same as rustango.