Questions tagged [rust-wasm]

121 questions
3
votes
1 answer

Using wasm_timer in Yew to execute callback repeatedly

I'm still rather new to Rust and have a hard time wrapping my head around futures. I want to implement a "timer app" in the browser and to do so I'm using https://yew.rs/. For the timer I tried to use https://github.com/tomaka/wasm-timer/, but there…
Achim
  • 15,415
  • 15
  • 80
  • 144
3
votes
1 answer

.Rlib and .d file instead of .wasm

I want to compile a .rs file in a Rust lib to a .wasm. RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown Instead of a .wasm file I get a .Rlib and .d file. What do I need to change to get a .wasm?
SurpriseMF
  • 174
  • 9
3
votes
0 answers

Return mutliple values from a wasm function

I have a Golang TCP server running locally and connected to a wasm module. Currently, I can return one value from a wasm function. Through this blog, I noticed that there should be possible to return multiple values rather than one. However, in my…
Hanif Tadjik
  • 73
  • 1
  • 7
3
votes
1 answer

How do I call a Rust function from Go with a string as a parameter?

I have been trying to pass a string to a Rust function (compiled to Wasm), however for what I understood, right now there is no way to pass strings directy, because the "str" is not a type in the "FFI world" (at least that's what the rust compiler…
JioFrost
  • 33
  • 7
2
votes
1 answer

Compute Shaders in Google chrome and Apple M1

I have a working physics simulator written in wgpu/rust that works when I am running from the command line. However, when I try to run on the chrome v114 (supported according to what I saw online), I get the following error saying the max number of…
Pap113
  • 37
  • 1
  • 7
2
votes
0 answers

Why does Cargo incorrectly compile Rust WASM global variables?

The following Rust compiled to WASM, based on the Wasmer exports_global.rs WASM example, produces incorrect WASM (with cargo build --target=wasm32-wasi): // (module // (global $one (export "one") f32 (f32.const 1)) // (global $some (export…
junglie85
  • 1,243
  • 10
  • 30
2
votes
1 answer

Rust Polars WebAssembly CSVReader

I am having an issue below when trying to upload a CSV file and parse it in web assembly polars using rust. Thanks Error: Grid.js:498 panicked at 'unsafe precondition(s) violated: ptr::read requires that the pointer argument is aligned and…
lallma
  • 31
  • 2
2
votes
1 answer

How do I remove this compiler error for use_store with yewdux?

I am learning yewdux and have implemented the tutorial code for global state: use yew::prelude::*; use yewdux::prelude::*; #[derive(Default, Clone, PartialEq, Eq, Store)] struct State { count: u32, } #[function_component] fn App() -> Html { …
Eli
  • 23
  • 3
2
votes
0 answers

Is there a way to integrate an arbitrary build command to a Cargo build?

At the end of a cargo build, I would like to call wasm-opt with specific optimization options on the generated WASM file. Unfortunately, it seems that the Cargo.toml does not support support asyncify options. A good solution would prevent cargo from…
rcora
  • 21
  • 3
2
votes
0 answers

How to return nested array from wasm_bindgen function

I have a rust program which I would like to run as web assembly in javascript. I have a function which I want to return a 3D array, so I can plot some data on a graph on the frontend, but I cannot find a way to return such data. Having a look at…
m.tracey
  • 173
  • 1
  • 10
2
votes
1 answer

Wasmd isn't installed

I have tried to install wasmd on Ubuntu. git clone https://github.com/CosmWasm/wasmd.git cd wasmd git checkout v0.23.0 make install But when I tried wasmd version, I met wasmd: command not found. It seems like the problem of PATH setting but I…
Bikas Lin
  • 689
  • 5
  • 16
2
votes
1 answer

How to separate yew components to different files?

I just started learning yew (frontend framework). How do i put every component in separate file, like in js frameworks. (i am using function components now)
smolovk
  • 61
  • 3
2
votes
2 answers

Caching Rust/Wasm tools in Gitlab CI?

I'm working with Wasm and Rust, and I'm deploying the page with gitlab pages. I'm using a gitlab-ci.yml file that looks like this: image: "rust:latest" variables: PUBLIC_URL: "/repo-name" pages: stage: deploy script: - rustup target add…
al3x
  • 589
  • 1
  • 4
  • 16
2
votes
0 answers

panicked at 'could not retreive random bytes for uuid: Node.js crypto module is unavailable'

I am writing some code in the rust and compiling it to wasm to run it using node.js runtime for lambda@edge. I need to generate the uuid as part of this code. I am doing that in rust and the code is compiling. But when I run, it is throwing below…
Vikas
  • 21
  • 3
2
votes
1 answer

`web_sys::Url::create_object_url_with_blob(&blob)` not formatting binary data correctly

I have the following code: let bytes: Vec = load_file_as_bytes("mydoc.docx"); // This gets a byte vec representation of the file mydoc.docx let uint8arr = unsafe { js_sys::Uint8Array::view(&bytes) }; let js_value =…
1
2
3
8 9