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
1 answer
How can I login with redirection (using POST)
I'm still trying to learn Rust and the YEW Framework (0.20).
Following the YEW tutorial only teaches you to Get data, and many online examples are not working for my case.
Is there a simple way to do this in YEW?
What I'm trying to do is :
Do a…

giri
- 33
- 7
0
votes
1 answer
Trunk: browser does not copy-dir
After running trunk serve command.
I've gotten the following:
However, the folder doesn't appear in the browser resources.
(There is not any trunk.toml file)

Guy-Arieli
- 33
- 7
0
votes
0 answers
Load functions from dll file in Rust and compile to WASM
I'm newbie in Rust, and trying to compile Rust code into WASM:
use libloading::{Library, Symbol};
use std::ffi::{CStr, CString};
use std::os::raw::c_char;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn main() {
// Load the DLL
let lib…

scorp1k
- 31
- 3
0
votes
1 answer
How does the Rust compiler make sense of log_u32 and log_many in the wasm-bindgen example below?
The following code is taken from the wasm-bindgen tutorial.
My question pertains to the code block that begins with
extern "C" and contains the functions log_u32 and log_many.
From what I understand, calling extern "C" lets you use C functions in…

Asker
- 1,299
- 2
- 14
- 31
0
votes
1 answer
How to create a request and use the data from an async request?
I'm working on a function which makes a request to an API, pulls the data, and parses it before returning the data as a Vector of a particular type. Because this is part of a Yew project, tokio and other packages are incompatible. I'm using the…

Jackie
- 198
- 12
0
votes
0 answers
Generated .wasm file contains an "import" that prohibits it from being used in Worker's thread
I've created a Rust lib with wasm-bindgen, compiled it to WASM using wasm-pack, and am trying to import it inside an AudioWorkletProcessor's thread.
On my main thread, I fetch the file and pass the resulting buffer to the Worker:
const audioContext…

Daniel Hadad
- 51
- 4
0
votes
0 answers
Cancel Rust function from JavaScript
I have a long running wasm function written in Rust which should be cancelable by the user (for example, by clicking a cancel button in the UI), that is, by a JavaScript event. My idea is to use a custom cancellation token like…

Dune
- 293
- 1
- 10
0
votes
1 answer
Rust/WebAssembly -- streaming HTTP request: convert JsValue from ReadableStreamDefaultReader.read into vector
I'm new to Rust and trying to implement a web page that shows a graph with many edges. I plan to use WebAssembly to lay out the graph and determine the positions of the nodes (and a WebGL library to draw the graph).
Context
I want Rust/wasm to make…

Simon Crowe
- 301
- 3
- 14
0
votes
0 answers
Understanding wasm-bindgen returned objects memory management
I'm trying to return a typed object from Rust to Typescript, and I ideally don't want to have to manually manage memory (performance is not the highest priority). While doing this, I'm trying to understand the generated JS.
Rust:
#[wasm_bindgen]
pub…

User
- 31,811
- 40
- 131
- 232
0
votes
1 answer
Seeing contents of `wasm_bindgen::JsError` in tests
I am writing a unit test for function like this, which compiles just fine:
#[wasm_bindgen]
pub fn my_fn(params_js: JsValue) -> Result {
// ...
}
But in my test, if a call to my_fn fails, I'm unable to see any details about the…

Jacob
- 77,566
- 24
- 149
- 228
0
votes
0 answers
Read file from GitHub Repo in React or Rust - begin
I am not super familiar with TypeScript. But I have a React file that executes a Rust program using WASM. The whole thing is being displayed on GitHub pages.
Now I want a dropdown menu - I am using MUI - that shows the files in a folder of that repo…

Dominik
- 123
- 1
- 1
- 6
0
votes
1 answer
Error when trying to compile into wasm, why?
I wrote a code that is compiled into wasm with rust, which includes the pfx file added when reqwest requests, but it prompts openssl error when compiling. What is the reason please?
error: failed to run custom build command for `openssl-sys…

xujizhong
- 42
- 3
0
votes
1 answer
WASM: run nginx inside wasm
Is it possible to run nginx inside wasm in the browser?
I'm imagining a webpage where you can enter an nginx config in a text box and then run nginx in wasm with an example request to get the output.

Test
- 962
- 9
- 26
0
votes
1 answer
How do I retrieve gamepad button pressed status from navigator.getGamepads() in Rust wasm-bindgen?
web_sys::Navigator.getGamepads() returns Result whereas I was hoping for an array of websys::Gamepad objects.
How do I parse whether a gamepad button is pressed from the wasm-bindgen::JsValue result? Is there some way to convert it…

user2880156
- 23
- 4
0
votes
0 answers
How safe would it be to let user load their wasm onto website
letting user load javascript onto website can lead to all sort of nasty side effects, is that the same with webassembly? I'm currently creating website that has long running components that will be displayed on livestreams (like youtube/twitch…

nxyt
- 113
- 5