0

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

3
  • 1
    Are you using wasm-pack or something? Commented Jul 12, 2020 at 12:19
  • I use wasm-pack Commented Jul 12, 2020 at 12:21
  • I am by no means a Rust expert, but don't you have to call .bytes() to get bytes from a String? Commented Jul 12, 2020 at 12:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.