1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! wry-bindgen-macro - Proc-macro for wasm_bindgen-style bindings
//!
//! This crate provides the `#[wasm_bindgen]` attribute macro that generates
//! code for Wry's WebView IPC protocol.
use TokenStream;
/// The main wasm_bindgen attribute macro.
///
/// This macro can be applied to `extern "C"` blocks to import JavaScript
/// functions and types, using the same syntax as the original wasm-bindgen.
///
/// # Example
///
/// ```ignore
/// use wry_bindgen::prelude::*;
///
/// #[wasm_bindgen]
/// extern "C" {
/// // Import a type
/// #[wasm_bindgen(extends = Node)]
/// pub type Element;
///
/// // Import a method
/// #[wasm_bindgen(method, js_name = getAttribute)]
/// pub fn get_attribute(this: &Element, name: &str) -> Option<String>;
///
/// // Import a getter
/// #[wasm_bindgen(method, getter)]
/// pub fn id(this: &Element) -> String;
///
/// // Import a constructor
/// #[wasm_bindgen(constructor)]
/// pub fn new() -> Element;
/// }
/// ```
/// Link to a JS file for use with workers/worklets.
///
/// This macro is only meaningful in WASM contexts. When running outside of WASM,
/// it will panic at runtime.
///
/// # Example
///
/// ```ignore
/// use web_sys::Worker;
/// let worker = Worker::new(&wasm_bindgen::link_to!(module = "/src/worker.js"));
/// ```