1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//! Sibling registration entry-point macro.
//!
//! Each sibling crate that ships a codec / container / filter / source
//! invokes [`crate::register!`] at module scope to declare its
//! `register(ctx)` function as the canonical entry point. The
//! [`oxideav-meta`](https://crates.io/crates/oxideav-meta) crate's
//! build script enumerates the enabled sibling deps in its Cargo.toml
//! and emits a `register_all(ctx)` body that calls the macro-generated
//! entry point of each.
//!
//! The macro is the dispatch contract between sibling and meta. Today
//! it expands to a thin `pub fn __oxideav_entry(ctx)` wrapper around
//! the user-supplied register fn. The macro body is the only place
//! that needs to change if the dispatch transport switches in the
//! future (e.g. add a metadata arg, defer init, async-init, audit
//! hook) — sibling call sites stay untouched.
//!
//! # Dispatch contract
//!
//! The contract has three fixed parts; the macro body is free to
//! change as long as they hold:
//!
//! 1. **Name and signature.** The expansion is exactly
//! `pub fn __oxideav_entry(ctx: &mut RuntimeContext)`. Callers
//! (today: `oxideav-meta`'s generated `register_all`) invoke it by
//! that name and nothing else.
//! 2. **Path.** Callers resolve it at the sibling's **crate root** —
//! `oxideav_<crate>::__oxideav_entry`. The macro defines the fn in
//! the module it is invoked from, so a sibling that invokes it
//! inside a submodule (`pub mod registry { … }`) **must re-export
//! it from the root**:
//!
//! ```ignore
//! // lib.rs
//! pub mod registry;
//! #[cfg(feature = "registry")]
//! pub use registry::__oxideav_entry;
//! ```
//!
//! Without the re-export the entry point only resolves at
//! `oxideav_<crate>::registry::__oxideav_entry`, and the meta crate
//! has to carry a per-sibling path override — a contract leak, not
//! a supported layout.
//! 3. **Effect.** One call installs the sibling's claims into `ctx`
//! exactly as the sibling's own `register(ctx)` would; calling it
//! twice on one context is the same as calling `register` twice
//! (codec ids gain a second implementation entry, container names
//! and schemes are replaced in place — see the registry docs).
//! Callers invoke it at most once per context.
//!
//! The wrapper is `#[doc(hidden)]`: it is dispatch plumbing, not a
//! sibling's public API, and semver tooling ignores it accordingly.
//!
//! # Standalone opt-out
//!
//! Each sibling's `register!()` call lives behind that crate's
//! default-on `registry` cargo feature. Consumers that want the
//! standalone (no-`oxideav-core`-dep) build path turn the feature off
//! and the macro call disappears.
/// Declare the canonical sibling entry point.
///
/// Place at module scope inside the sibling crate, gated behind the
/// crate's `registry` cargo feature so the standalone build path
/// stays decoupled from `oxideav-core`:
///
/// ```ignore
/// pub fn register(ctx: &mut oxideav_core::RuntimeContext) {
/// /* install factories */
/// }
///
/// #[cfg(feature = "registry")]
/// oxideav_core::register!("aac", register);
/// ```
///
/// The macro expands to a `pub fn __oxideav_entry(ctx)` wrapper that
/// invokes the supplied function. `oxideav-meta`'s `register_all`
/// calls `oxideav_<crate>::__oxideav_entry(ctx)` for each enabled
/// sibling dep — the fn must therefore be reachable at the crate
/// root; when the macro is invoked in a submodule, add
/// `pub use <module>::__oxideav_entry;` to `lib.rs` (see the module
/// docs, "Dispatch contract").
///
/// The display-name argument (first literal) is reserved for future
/// dispatch-transport changes; it is currently ignored by the
/// expansion but kept in the macro signature for forward
/// compatibility.