rustango_orm_macros/lib.rs
1//! Proc-macros for the standalone `rustango-orm` crate — carve-out
2//! of [`rustango-macros`](https://docs.rs/rustango-macros).
3//!
4//! This crate re-exports the ORM-only proc-macros from the
5//! workspace's `rustango-macros` crate:
6//!
7//! - [`Model`] — `#[derive(Model)]` populates the model schema,
8//! generates inherent methods (insert / save / delete / find /
9//! where_ / sum / etc.), and registers the model with the
10//! `inventory` crate so the admin walks every derived model.
11//! - [`Form`] — `#[derive(Form)]` validates user input and parses
12//! it into a strongly-typed struct.
13//! - [`embed_migrations!`] — bakes a `migrations/` directory's
14//! `.json` files into a `&'static [(name, content)]` slice at
15//! compile time.
16//!
17//! The framework-only derives (`Serializer`, `ViewSet`, `Q!`,
18//! `#[rustango::main]`) stay in `rustango-macros`. Downstream code
19//! that depends only on `rustango-orm-macros` literally cannot
20//! reach them — that's the carve-out half of issue
21//! [#143](https://github.com/ujeenet/rustango/issues/143).
22//!
23//! ## How re-export works for proc-macros
24//!
25//! Rust's resolver follows `pub use` paths to find a proc-macro's
26//! defining crate. The consumer writes:
27//!
28//! ```ignore
29//! use rustango_orm_macros::Model;
30//!
31//! #[derive(Model)]
32//! pub struct Post { … }
33//! ```
34//!
35//! …and the compiler looks up `Model` in this crate's scope, sees
36//! it's a re-export of `rustango_macros::Model`, walks back to the
37//! `proc-macro = true` crate where the derive is actually defined,
38//! and invokes the proc-macro entry point.
39//!
40//! Because of how proc-macros work, the re-exporter itself doesn't
41//! need `proc-macro = true`. This is a regular `[lib]` crate.
42//!
43//! After issue [#144](https://github.com/ujeenet/rustango/issues/144)
44//! lands (the physical move of the ORM modules to a standalone
45//! `rustango-orm` crate), the proc-macro bodies themselves will
46//! migrate here and `rustango-macros` will drop them, completing
47//! the carve-out.
48
49#![warn(missing_docs)]
50
51pub use rustango_macros::{embed_migrations, Form, Model};