reflow_pack_macro 0.2.1

Proc macro for authoring Reflow actor packs — emits the cdylib entrypoints required by reflow_pack_loader.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 7.62 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 281.6 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • offbit-ai/reflow
    17 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • darmie

#[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 PackHostVtable through 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.