macro_rules! wasm_init { ($($input:tt)*) => { ... }; }
Expand description
Register code to be run on start-up.
Each call to this macro will generate a function that will be called exactly once, after the wasm_init function is called for the first time.
You can register code from as many different crates in your project as you’d like; wasm_init only needs to be called once.
Examples
trait Plugin {}
fn register_plugin(plugin: impl Plugin) {
// grab data from each plugin and store them in a global somewhere
}
struct Plugin1;
wasm_init::wasm_init! {
register_plugin(Plugin1);
}
struct Plugin2;
wasm_init::wasm_init! {
register_plugin(Plugin2);
}