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
//! Distributed-slice auto-registration.
//!
//! Each sibling crate that ships a codec / container / filter / source
//! deposits a [`Registrar`] into the global [`REGISTRARS`] slice via the
//! [`crate::register!`] macro. [`RuntimeContext::with_all_features`]
//! walks the slice and invokes every registrar exactly once on the
//! `RuntimeContext` it's building.
//!
//! This replaces the historical umbrella-driven registration where
//! `oxideav::with_all_features()` enumerated every sibling explicitly.
//! With the slice, a sibling registers itself just by being linked into
//! the binary — no umbrella plumbing required. Consumers depend on the
//! sibling crates they want; pulling them in is enough.
//!
//! # 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 — no linkme entry, no slice
//! contribution.
//!
//! # Wasm
//!
//! linkme's distributed-slice machinery works on `wasm32-unknown-unknown`
//! and `wasm32-wasi` via wasm-ld's section grouping (recent stable
//! Rust toolchains ship a recent enough lld). The classic
//! `__attribute__((constructor))` path used by `ctor` / `inventory`
//! does NOT work on wasm; this is the deliberate reason linkme was
//! chosen over those.
use crateRuntimeContext;
/// One entry in the distributed registrar slice. Carries the sibling
/// crate's display name (for the `with_all_features_traced` hook +
/// `with_all_features_filtered` opt-out filter) plus the function
/// pointer to invoke against the runtime context.
/// Global slice of registrars. Each sibling crate's
/// [`crate::register!`] call deposits one entry here; the slice is
/// materialised at link time.
pub static REGISTRARS: ;
/// Auto-register a sibling crate's `register` fn into the global
/// [`REGISTRARS`] slice.
///
/// 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 `#[linkme::distributed_slice]` static. The
/// sibling crate must have `linkme = "0.3"` in its `[dependencies]`
/// so the absolute path `::linkme::distributed_slice` resolves at
/// macro expansion time.