Questions tagged [rust-wasm]

121 questions
1
vote
0 answers

What is the equivalent working Rust code example for this WAT (WebAssembly Text) example?

The below WAT, adapted from a couple of Wasmtime examples, runs absolutely fine embedded in my application but what I thought was the equivalent Rust code fails with: Running `target\debug\hello_world.exe` Error: expected 5 imports, found 1 error:…
junglie85
  • 1,243
  • 10
  • 30
1
vote
3 answers

the `wasm32-wasi` target may not be installed while it is installed

why cargo build --target wasm32-wasi throws and error about not having wasm32-wasi while it is installed. steps to reproduce cargo new train rustup target add wasm32-wasi cargo build --target wasm32-wasi the output to the console is next ➜ train…
Victor Orlyk
  • 1,454
  • 2
  • 15
  • 27
1
vote
1 answer

How can I get the total number of files at build time and then pass it to web assembly in Yew?

I'm currently building an image carousel. I want to count the contents of a directory that is only accessible at the OS level and pass the result to a static hashmap inside a web assembly module in Yew. Here's a use_reducer paired with a Context in…
Jose A
  • 10,053
  • 11
  • 75
  • 108
1
vote
0 answers

How do I compile an existing C++ ibrary using sockets to WASM?

I have some existing server code written in C++, Node.js and Python that I would like to port to WASM. This code makes heavy use of UDP/TCP sockets. Ideally with little to no modification of the code. I know this type of question has been asked a…
1
vote
1 answer

how to overcome memory limit on vector allocation in rust code assembled to WASM binaries

Update: created a small test app (react calling wasm rust code) but cant recreate rust exception, however this one liner is an extract from bit bigger function and I am still on to find what particular combo is leading to this…
1
vote
0 answers

Error compiling dependency to a proc-macro when targeting wasm

I have a procedural macro I have implemented which depends on the proc-macro-error crate. My client project depends on this macro crate. When I build for native, everything works perfectly, but when I build for wasm, I get a number of errors thrown…
sak
  • 2,612
  • 24
  • 55
1
vote
1 answer

How do I exclude an architecture with cfg?

I'm working on a project which should target wasm, but some functionality will not be supported. It looks like I can conditionally include a function in this way: #[cfg(target_arch = "wasm32")] fn my_func() { ... } Or conditionally call it like…
sak
  • 2,612
  • 24
  • 55
1
vote
0 answers

RuntimeError: memory access out of bounds in WASM

I am currently building a small project that outsources it's processing into wasm compiled from rust. I am using wasm-bindgen, wasm-pack and webpack. Shortly after the WASM is instantiated, I get the error described above. When looking at the wat…
leonhma
  • 110
  • 9
1
vote
2 answers

How to return a vector of vectors in Rust + WASM?

I want to create a function find which accepts a matrix argument with type Vec> and returns another matrix with type Vec>. Unfortunately, wasm_bindgen complains that types are not "compatible". use…
Roman Mahotskyi
  • 4,576
  • 5
  • 35
  • 68
1
vote
0 answers

Instantiating & freeing a WASM module repeatedly causes "Memory Access out of bounds"

I'm using wasm-bindgen to build a simple Rust struct with constructor that takes a JS closure, and run it in node.js. use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct WasmThing { func: Box, } #[wasm_bindgen] impl WasmThing…
Ari Lotter
  • 605
  • 8
  • 23
1
vote
2 answers

How to invoke (Rust) web-sys AngleInstancedArrays?

https://developer.mozilla.org/en-US/docs/Web/API/ANGLE_instanced_arrays Given WebGL2RenderingContext as gl. We have gl.draw_arrays_instanced. There is also a web-sys object: web_sys::AngleInstancedArrays with functions like…
kulicuu
  • 15
  • 5
1
vote
1 answer

Will private functions be included when I compile a rust project to WASM?

If I have a lib.rs file and I'm using a function from a module in the mod.rs file, and that function uses another function within the mod.rs file but isn't made public to lib.rs. Thus is inaccessible to the lib.rs. What happens if I publish my…
rewfsdv
  • 61
  • 5
1
vote
1 answer

Safety of storing secrets in WASM file

I am quite new to WebAssembly and am trying to wrap my head around how it works. From what I understand, one calls a WASM module in javascript and supplies arguments. I know that such arguments themselves are publicly viewable by the client because…
user17832896
  • 55
  • 1
  • 1
  • 5
1
vote
0 answers

Could not find `Cargo.toml` running Cargo in docker container

I am using the code: docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ …
1
vote
1 answer

How to import WasmMemory without a bundler?

I was following the tutorial on making a WASM application with Rust. I decided on not using a bundler, but I stumbled upon a question. When using a bundler, to access WASM's memory, I can simply import { memory } from "/_bg", but…
Marcelo43
  • 57
  • 7
1 2 3
8 9