Expand description
#[reflow_pack] — wraps a user function fn(&mut PackHost) with
the entrypoints the loader expects a pack to export.
§Two ABIs, one source crate
Pack source crates produce two distinct binary shapes from the same Rust:
- Native cdylib (
dlopen/LoadLibrary). Loader passes a*mut PackHostVtablethrough the standard C ABI; the pack’s register function fills it with template factories and returns a status. - Browser wasm (
WebAssembly.instantiate). The pack wasm imports a single JS callback (__reflow_pack_register_template), and exports a no-arg registration function the JS loader calls right after instantiation. The pack walks the user’s register function once, calling the JS import for each template, then stashes the factories in a process-static table keyed by an integer id. JS hands those ids back to__reflow_pack_create_actor(id)whenever the runtime needs a fresh actor instance.
Both ABIs route through the same user-written register function;
the macro emits whichever entrypoints are appropriate for the
target. See crates/reflow_pack_loader/src/lib.rs for the native
loader and sdk/node/reflow.browser.mjs::loadPack for the
browser one.
Attribute Macros§
- reflow_
pack - Mark a function as the pack’s registration entrypoint.