Questions tagged [rust-wasm]

121 questions
0
votes
1 answer

How do you configure a mados scCall step for VarArgs MultiArg endpoint argument with a struct as argument?

I'm trying to create an elrond smart contract that would allow multiple elements to be sent at once to reduce the number of transactions to send the initial information to the contract. To do so, I'm using an endpoint that takes into an argument a…
0
votes
0 answers

Rust wasm: When is it legal to call JS new X() on a Rust X::new() annotated with wasm_bindgen(constructor)?

Given the following (simplified) Rust code: #[wasm_bindgen(js_name = MyClass)] pub struct MyClassJs { my_struct: MyStruct, } #[wasm_bindgen(js_class = MyClass)] impl MyClassJs { #[wasm_bindgen(constructor)] pub async fn new() ->…
Erik Živković
  • 4,867
  • 2
  • 35
  • 53
0
votes
0 answers

Rust, SDL2, Emscripten and 'Invalid renderer' panic

It seems like the combination of Rust, SDL2, and Emscripten is something that some people have made to work at various points in the past. https://github.com/Rust-SDL2/rust-sdl2/issues/884 I have an issue that has me a bit stumped. I'm a complete…
Greg Buchholz
  • 900
  • 4
  • 17
0
votes
0 answers

Rust wasm module build error (x11-clipboard dependency)

Recently I knew about web assembly and was messing around with it in rust. Eventually I run into build problem. My toml file looks like this [package] name = "clipboard-manager" version = "0.1.0" edition = "2018" # See more keys and their…
0
votes
1 answer

oxipng throwing RuntimeError: unreachable when called

I'm trying to create a small WASM project for image compression. After some search in github, I noticed that oxipng 2.2.2 has a target for wasm32-unknown-unknown, hence why I'm using that. I'm using wasm-pack for creating the wasm file + JS bindings…
Vanethos
  • 691
  • 1
  • 8
  • 20
0
votes
0 answers

Return typescript union with wasm_bindgen

Suppose I have the following rust structs: struct NumberNode { val: i64 } struct StringNode { val: String } pub enum Node { Number(NumberNode), String(StringNode), } I would like to annotate Node with #[wasm_bindgen] so I can…
Elias
  • 3,592
  • 2
  • 19
  • 42
0
votes
1 answer

Best practice to secure wasm binary

I'm developing a PWA app that will possibly include a rust wasm binary. The binary executes a task that should be purchased. Are there any best practices for securing the binary so that it can't be executed without authorization?
kenianbei
  • 88
  • 1
  • 3
0
votes
1 answer

Rust imports in wasm-pack code causing JS error

I'm getting a JS error: Uncaught (in promise) TypeError: WebAssembly.instantiate(): Import #0 module="env" error: module is not an object or function When I view the wasm file in the Chrome dev tools, I see import statements like this, at the…
user1558646
  • 145
  • 4
  • 9
0
votes
1 answer

Environment detection in WASM: Web, Node.js or standalone runtime?

There are many ways to run a WebAssembly module, besides Web, Node.js can load wasm module with --experimental-wasm-modules, standalone runtime like wasmtime and lucet can run it too. So how do I detect the current environment in WASM and is it…
Jian
  • 3,118
  • 2
  • 22
  • 36
0
votes
0 answers

Importing WASM from a express server

recently I've been coding in Rust WASM and compiling using wasm pack. When I had finished coding, I put the compiled files into my static folder, (I can confirm that they are static), and tried to import them in my HTML file. I keep getting this…
Artrix
  • 149
  • 10
0
votes
1 answer

Why does i got lifetime error in rust closure

I'm testing some rust wasm features, and have some problem with closures. I'm implemented this function, which setup callback on button click event. pub fn setup_click(&mut self) { let mut clicks = 0; let ws_cloned = self.websocket.clone(); …
0
votes
1 answer

How can I get the browser's local timezone using Rust js_sys?

I am using the js_sys crate to run some Rust code in the browser. Having difficulty to understand how to use Intl::DateTimeFormat. All I want is to get the local timezone, which is done with this JS code: const tz =…
Renato
  • 12,940
  • 3
  • 54
  • 85
-1
votes
1 answer

Unable to build wasm-pack project - `wasm-opt` download failed

wasm-pack is unable to download the required tools for optimizing wasm-opt. This fails the build. I'm left with only option of disabling wasm optimizations with wasm-opt = false. $ wasm-pack build failed with error Error: failed to download from…
Arjun
  • 3,248
  • 18
  • 35
-1
votes
0 answers

wasm-pack is not building when there is a C dependency

One of my dependency uses C to build. When I run wasm-pack build --target web, it throws an error saying that the standard libraries are not found. running: "clang" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC"…
xmuhs
  • 96
  • 1
  • 9
-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
1 2 3
8
9