We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have the following code in my Rust project:
#[no_mangle] #[wasm_bindgen] pub fn test(str: String) -> String { test_internal(json::parse(str.as_str()).unwrap()).into() } #[no_mangle] pub fn test_internal(json_value: JsonValue) -> Message { let age: Result<u8, _> = json_value.find("age"); Message::new(vec![format!("Age {}.", age.unwrap())]) }
I've generated the .wasm with wasm-pack build --release, and in the Java side I have:
.wasm
wasm-pack build --release
// Reads the WebAssembly module as bytes. byte[] wasmBytes = Files.readAllBytes(wasmFilePath.get()); // Instantiates the WebAssembly module. Instance instance = new Instance(wasmBytes); // Calls an exported function, and returns an object array. ObjectMapper om = new ObjectMapper(); String s = om.writeValueAsString(myObject); Object[] results = instance.exports.getFunction("test") .apply(s); // Drops an instance object pointer which is stored in Rust. instance.close(); return (String) results[0];
But when trying to run the code above, it fails with the following exception:
Failed to convert the argument 0nth of `test` into a WebAssembly value.
Doing a bit of investigation, I've found that String conversion is not implemented, only minimal primitive types are.
String
Correctly convert from-to string between Rust Wasm and Java.
Fails with an exception.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
I have the following code in my Rust project:
I've generated the
.wasm
withwasm-pack build --release
, and in the Java side I have:But when trying to run the code above, it fails with the following exception:
Doing a bit of investigation, I've found that
String
conversion is not implemented, only minimal primitive types are.Steps to reproduce
wasm-pack build --release
Expected behavior
Correctly convert from-to string between Rust Wasm and Java.
Actual behavior
Fails with an exception.
The text was updated successfully, but these errors were encountered: