Expand description
Proc-macros for the standalone rustango-orm crate — carve-out
of rustango-macros.
This crate re-exports the ORM-only proc-macros from the
workspace’s rustango-macros crate:
Model—#[derive(Model)]populates the model schema, generates inherent methods (insert / save / delete / find / where_ / sum / etc.), and registers the model with theinventorycrate so the admin walks every derived model.Form—#[derive(Form)]validates user input and parses it into a strongly-typed struct.embed_migrations!— bakes amigrations/directory’s.jsonfiles into a&'static [(name, content)]slice at compile time.
The framework-only derives (Serializer, ViewSet, Q!,
#[rustango::main]) stay in rustango-macros. Downstream code
that depends only on rustango-orm-macros literally cannot
reach them — that’s the carve-out half of issue
#143.
§How re-export works for proc-macros
Rust’s resolver follows pub use paths to find a proc-macro’s
defining crate. The consumer writes:
use rustango_orm_macros::Model;
#[derive(Model)]
pub struct Post { … }…and the compiler looks up Model in this crate’s scope, sees
it’s a re-export of rustango_macros::Model, walks back to the
proc-macro = true crate where the derive is actually defined,
and invokes the proc-macro entry point.
Because of how proc-macros work, the re-exporter itself doesn’t
need proc-macro = true. This is a regular [lib] crate.
After issue #144
lands (the physical move of the ORM modules to a standalone
rustango-orm crate), the proc-macro bodies themselves will
migrate here and rustango-macros will drop them, completing
the carve-out.
Macros§
- embed_
migrations - Bake every
*.jsonmigration file in a directory into the binary at compile time. Returns a&'static [(&'static str, &'static str)]of(name, json_content)pairs, lex-sorted by file stem.