link_anchor!() { /* proc-macro */ }Expand description
Emit a once-per-crate linkage anchor so an adopter binary can force
link-time retention of THIS crate’s #[derive(Model)] registrations
without listing every model type (#370, branch b).
§What
Invoke djogi::link_anchor!(); exactly once in a model crate’s
lib.rs. It emits a #[used] static (<crate>::__DJOGI_LINK_ANCHOR)
the dead-strip defense — plus a callable <crate>::__djogi_link_anchor()
fn (returning &'static ()) that the adopter glue references once per
crate. Referencing that fn pulls the crate’s rlib member into the binary,
and the crate’s inventory statics are collected.
§Usage
ⓘ
// In each model crate's lib.rs, once:
djogi::link_anchor!();
// In the adopter's src/bin/djogi.rs, one reference per model crate:
fn main() -> std::process::ExitCode {
tracker::__djogi_link_anchor();
billing::__djogi_link_anchor();
djogi_cli::run_from_env()
}