I have a part of code written in Rust and I want to get some bytes in JS.
file.rs
:
#[no_mangle]
pub extern "C" fn get_char_successfully() -> char {
'a'
}
#[no_mangle]
pub extern "C" fn get_bytes_unsuccessfully() -> String {
String::from("string");
}
file.js
:
const rs = await import('../file-rs.wasm')
let a = rs.get_char_successfully(); // work
let b = get_bytes_unsuccessfully(); // not working, empty
I use wasm-pack