Skip to main content

wasm_export

Function wasm_export 

Source
pub(crate) fn wasm_export(item: TokenStream) -> TokenStream
Expand description

Processes an impl block, transforming methods marked with #[wasm_only].

For each marked method:

  • Strips the #[wasm_only] marker attribute
  • Renames the method with a __wasm_only_ prefix (e.g. subscribe -> __wasm_only_subscribe)
  • Adds #[wasm_bindgen(js_name = "original_name")] if no js_name is already present
  • Adds #[doc(hidden)] to hide it from Rust documentation
  • Adds #[deprecated] so it shows with strikethrough in IDE autocomplete

This makes the methods effectively unreachable from Rust (hidden, mangled name) while preserving the original JS-facing API through wasm_bindgen’s js_name attribute.