#[func]Expand description
Attribute macro: translate ONE JS source at compile time and replace the annotated fn with the translated handler (P-A3).
ⓘ
#[js2rust_bridge_macro::func(
config = "js2rust.toml", // relative to CARGO_MANIFEST_DIR
source = "func/create_sms.js", // relative to corpus root, required
scope = "gen", // module providing Host/Route/types,
)] // default: no scope imports
async fn create_sms_stub() {} // name kept; signature replacedThe stub fn is discarded — only its name, visibility, and docs are kept.
The macro runs the same Rust→Rhai translation tiers as the offline
pipeline and emits: a private module (scope imports + regenerated
handler + per-script host-fn register fn + include_bytes! sentinels
tracking the JS source, the config, and the GraphQL schema), plus a
re-export of the handler under the stub’s name. Editing the JS source
or the schema triggers a rebuild of the generated handler.