wasm_bindgen_test/rt/
node.rs1use alloc::string::String;
7use wasm_bindgen::prelude::*;
8
9pub struct Node {}
11
12#[wasm_bindgen]
13extern "C" {
14 type NodeError;
17 #[wasm_bindgen(method, getter, js_class = "Error", structural)]
18 fn stack(this: &NodeError) -> Option<String>;
19 #[wasm_bindgen(method, js_class = "Error", js_name = toString, structural, catch)]
20 fn to_string(this: &NodeError) -> Result<String, JsValue>;
21 #[wasm_bindgen(js_name = __wbgtest_og_console_log)]
22 fn og_console_log(s: &str);
23}
24
25impl Node {
26 pub fn new() -> Node {
28 Node {}
29 }
30}
31
32impl super::Formatter for Node {
33 fn writeln(&self, line: &str) {
34 og_console_log(line);
35 }
36
37 fn stringify_error(&self, err: &JsValue) -> String {
38 let err = NodeError::from(err.clone());
40 err.stack().unwrap_or(err.to_string().unwrap_or("".into()))
41 }
42}
43
44#[wasm_bindgen]
46pub fn __wbgtest_coverage_path(
47 env: Option<String>,
48 pid: u32,
49 temp_dir: &str,
50 module_signature: u64,
51) -> String {
52 wasm_bindgen_test_shared::coverage_path(env.as_deref(), pid, temp_dir, module_signature)
53}