wasm-bindgen is a rust crate for facilitating high-level interactions between WebAssembly (Wasm) modules and JavaScript.
Questions tagged [wasm-bindgen]
254 questions
0
votes
2 answers
"RuntimeError : Memory access out of bounds" when trying to save a string in Wasm heap and then saving the pointer to the string in a struct
I am trying to save a String in Wasm heap as Uint8Array after encoding and saving the pointer to the string and the length in a Struct so that i can access the string later. Below is My code in rust
#[wasm_bindgen]
pub struct CustomString{
ptr :…

UJJAL DUTTA
- 93
- 2
- 8
0
votes
1 answer
How to with wasm-bindgen - import js with more than one module level
Following example https://github.com/rustwasm/wasm-bindgen/tree/master/examples/import_js works fine. Next step I try to import a js-module with 2 levels of modules. Let MyClass instead be referenced with mylib.part1.MyClass.
In rust wasm-bindgen…

Jonas Bojesen
- 855
- 1
- 8
- 22
0
votes
1 answer
How to put a trait Bound to elements built with document.create_element
Working on a minimal prototype/test program for Dom manipulation using Rust and wasm-bindgen.
Building the element with document.create_element(tag), which returns a web_sys::Element. The element is casted to specific type, depending on tag e.g.…

Jonas Bojesen
- 855
- 1
- 8
- 22
0
votes
1 answer
unable to import local wasm npm package in shadow-cljs project
I am playing arounf trying to import wasm packages in my shadow-cljs project. It is bundled in a npm package, but i keep getting this error:
The required JS dependency "canvas" is not available, it was required by "canvas/core.cljs".
this is my…

Le Marin
- 135
- 1
- 12
0
votes
1 answer
how can I implement an external trait on an internal trait in Rust?
I want to print the instance of Tweet datatype in main function, but the summary trait don't implement the debug trait. Is there any way to implement a trait on trait or any work around.
uncommentating the second line and commentating the first line…

Areeb Sid
- 13
- 2
0
votes
1 answer
Downloading same files twice under Network tab in browser (WASM file referred in JS file)
WASM file gets downloaded twice, Is there anyway we can avoid downloading same file more than once.
here ERT_Facial_Alignment_asm.js referring to ERT_Facial_Alignment_asm.wasm file, but wasm downloaded twice.
Please find attached file here.

Vasant
- 101
- 2
- 10
0
votes
1 answer
Is there are way to re-webapck npm package, using wasm which was webpacked ans use it for vscode plugin development?
First of all, I created the npm package which uses wasm converted from rust-lang using wasm-pack.
https://www.npmjs.com/package/markdown_img_url_editor
node_modules/markdown_img_url_editor:
Now, I want to re-webpack the package and use…

yumetodo
- 1,147
- 7
- 19
0
votes
1 answer
type mismatch resolving future_to_promise
I'm trying to do below:
Receive function via argument
Execute the function that returns Promise
Wait Promise to be resolved
Execute something
return Promise
fn get_replaced(parser: Parser, string_generators: Vec, initial_capacity: usize)…

yumetodo
- 1,147
- 7
- 19
0
votes
2 answers
DOMException when hot-loading Web Audio worklet processor with Wasm modules from a Blob?
I'm trying to load dynamic Web Audio worklets with Wasm module imports transpiled from C++ code using Emscripten.
I want to manipulate worklets code in memory, using Blob to create objects, injecting them as modules into the audio worklet, and…

Francisco Bernardo
- 87
- 1
- 11
0
votes
1 answer
Out of memory WebAssembly Instantiation in Cloudflare Workers
I am building a WebAssembly module in Rust to be used in Cloudflare Workers, via wasm-bindgen. The module is overall very basic; it has a single function named process, which takes as inputs two binaries (represented by two Uint8BitArrays), and a…

Edouard
- 149
- 1
- 11
-1
votes
0 answers
an efficient way to deal with sending large files over WebSocket and WebRTC
I'm building an app using yew and wasm to share files locally using WebRTC, however I'm having a difficult time finding a way to properly do the different file conversions, I will be converting the uploaded file to vec to chunk them and send them,…

abdesamed
- 34
- 1
- 3
-1
votes
1 answer
What exactly happens when you write a function in rust and call it in the a JavaScript file?
Apparently making a web application using rust and wasm make it run faster. Your rust code uses web assembly as a compilation target and your rust code is compiled into web assembly, this web assembly is run in the browsers web assembler machine ,…

PurpleMoneys89
- 11
- 2
-1
votes
1 answer
In Rust WASM Game of Life tutorial, can't get the mouse click event to work
Problem: Can't seem to get the mouse click toggle event working. On clicking, a live cell should turn dead and a dead cell should turn alive.
I have uploaded the Rust/WASM Game of Life tutorial project in this Github Repo for those who want to find…

arnabanimesh
- 275
- 3
- 11
-2
votes
1 answer
How to add an event listener to some HTML element from Rust which calls a trivial JS function?
I have the "on_event" JS function:
function on_event(event) {
console.log(event);
}
And I have the "button" HTML element builder in Rust:
let window = web_sys::window().expect("no `window` object");
let document = window.document().expect("no…

Nick Nizovtsev
- 233
- 1
- 10