Questions tagged [wasm-bindgen]

wasm-bindgen is a rust crate for facilitating high-level interactions between WebAssembly (Wasm) modules and JavaScript.

254 questions
0
votes
1 answer

type mismatch resolving ::Output == std::result::Result

I am trying to implement an API class using wasm_bindgen with asynchronous calls. #![allow(non_snake_case)] use std::future::Future; use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use…
Fomalhaut
  • 8,590
  • 8
  • 51
  • 95
0
votes
1 answer

How do I use some wasm files for other javascript projects which are not dependent on wasm-pack?

Can I call functions declared in wasm files from any javascript? Wasm files were built by wasm-pack with Rust lang, wasm-pack, wasm-bindgen and webpack. They are working fine in the original environment. I want to use some wasm files for other…
skatori
  • 547
  • 6
  • 20
0
votes
1 answer

How do I decouple wasm specific macros from functions and structs

I've got some core functionality, primarily an algorithm that i'm trying to reuse in web assembly and java. I'm using wasm-bindgen and serde, I notice that wasm-bindgen and serde is tightly coupled to my algorithm via the use of attributes. i.e;…
Grant
  • 446
  • 6
  • 24
0
votes
1 answer

How to pass an array of primitive element type from javascript to wasm in Rust fast?

Let me ask how to pass an array holding uint8 elements from javascript to wasm in Rust fast? I found one method in: As JsValue. Though I wonder if there is some clearly faster one when all element values are same primitive type and in a particular…
skatori
  • 547
  • 6
  • 20
0
votes
1 answer

rust-lld: error: unable to find library -lpq

I'm trying to build a simple web app using Yew, Diesel, and Postgres. When I run wasm-pack build --target web --out-name wasm --out-dir ./static I get the following error: *rust-lld: error: unable to find library -lpq* I'm on macOS Catalina. I…
nalin
  • 3
  • 5
0
votes
1 answer

wasm-bindgen - possible to identify build version / date?

With webapplications the dev loop [change -> build -> deploy -> test] is very iterative. Due to browser caches easy to mistake the build version. Hence very often neccesary to identify the build version. Does wasm-bindgen/wasm-pack provide some…
Jonas Bojesen
  • 855
  • 1
  • 8
  • 22
0
votes
1 answer

How to access web_sys::CustomEvent.detail data from rust

Have code which generates an https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.CustomEvent.html. Logging event.detail() results in: {index: 1}. This is of type JsValue, but how to obtain the integer 1 value in rust? One way could…
Jonas Bojesen
  • 855
  • 1
  • 8
  • 22
0
votes
0 answers

The trait `rayon::iter::ParallelExtend` is not implemented for `std::vec::Vec

I am trying to convert Roliz's web crawler (blog post) into WASM for in-browser or Deno-based endpoint crawling. Here is my implementation: Cargo.toml [dependencies] wasm-bindgen = "0.2.67" wasm-bindgen-futures = "0.4.17" rayon =…
Eidolon
  • 309
  • 3
  • 12
0
votes
0 answers

Customizing Style of WinUI ProgressRing Not Available on WASM with Uno 2.4

I know globally modifying theme colors with template binding way not supported in Uno yet. (I tried it for ToggleSwitch, now ToggleSwitch custom style runs perfectly both on UWP and WASM). So, I prepared a custom style for WinUI 2.4 ProgressRing in…
berkb
  • 542
  • 6
  • 21
0
votes
1 answer

worker-loader cannot work with wasm-loader and typescript in react project

I've tried: // Worker.ts // @ts-ignore // eslint-disable-next-line no-restricted-globals const ctx: Worker = self as any; // Post data to parent thread // ctx.postMessage({ foo: "foo" }); // Respond to message from parent…
Aero Wang
  • 8,382
  • 14
  • 63
  • 99
0
votes
3 answers

wasm-bindgen: command not found even though wasm-pack is installed (0.8.1)

From this article https://asquera.de/blog/2018-10-01/webassembly-and-wasm-bindgen/ I found we can run wasm-bindgen target/wasm32-unknown-unknown/release/qr_wasm.wasm --out-dir ./dist --no-modules --no-typescript to create wasm and js files without…
Aero Wang
  • 8,382
  • 14
  • 63
  • 99
0
votes
0 answers

Webassembly in rust executable binary

Is it possible to compile webassembly code in the executable? What I mean by that is that you have an executable, which also serves some interface to javascript via webassembly. Right now my project is separated into two, both written in Rust. One…
Xeizzeth
  • 441
  • 1
  • 3
  • 10
0
votes
0 answers

Is there more efficient way to iterate through array of js objects in wasm-bindgen?

This is my wasm-bindgen code: #[wasm_bindgen] pub fn iteration(js_array: &JsValue) -> Vec { let elements: Vec = js_array.into_serde().unwrap(); elements.iter().fold(vec![], |mut acc, duck| { let id =…
0
votes
1 answer

How can I change a variables value from an async block without taking ownership of it

I'm pretty new to rust, trying to make a small game with web assembly using rust and wasm-bindgen. I have an event listener which listens for key presses, and returns a direction through a Stream. Then I want to draw something to a canvas element…
Christian Fosli
  • 1,646
  • 9
  • 14
0
votes
1 answer

How to put a trait bound for web_sys::HtmlElement::from function

With e_text of type web_sys::HtmlDivElement and e_button of type web_sys::HtmlButtonElement this function builds a Closure to a on_click callback. Compiles and runs ok. let a = buildCbClosure(web_sys::HtmlElement::from(e_text)); fn…
Jonas Bojesen
  • 855
  • 1
  • 8
  • 22
1 2 3
16
17