283 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
0
answers
224
views
RuntimeError: unreachable executed from wasm-bindgen
My website has the following JS code running the generated WASM:
import init, {
solve_abrams_strogatz
} from './pkg/langshift.js';
async function run() {
await init();
console.log("...
1
vote
1
answer
85
views
RuntimeError: memory access out of bounds for wasm-bindgen and wasm-pack
I am trying to call a Rust -> wasm function from a simple web page. Getting an error despite keeping it all simple. The function in question merely takes two string arguments and returns one string ...
0
votes
1
answer
186
views
How should I structure this websocket-based WASM app?
I'm trying to build a frontend application using rust wasm and a websocket to connect to the server. Here's the desired core logic:
Server (axum) needs to send a command to the app
Server creates an ...
1
vote
0
answers
96
views
How do I import WASM in Worker JS in a Vue 3 project powered by Vite?
I am trying to request a WASM function within a JS Worker. I am stuck with it because nothing works in the way I have tried, but also I cannot see any error. Let me explain what I am doing.
First, I ...
1
vote
1
answer
173
views
Why can't I call `from_serde` from Rust wasm-bindgen function?
I am using Rust via WASM inside an Angular app. I am looking to filter the objects by key.
Here is my Rust Cargo.toml and lib.rs:
[package]
name = "my-rust-wasm"
version = "0.1.0"
...
3
votes
1
answer
91
views
What does `.map_err(|_| ())` do in this web-sys canvas example?
I'm reading through the canvas hello world example in the wasm-bindgen docs, and I'm confused about this part of the code:
#[wasm_bindgen(start)]
fn start() {
let document = web_sys::window()....
0
votes
1
answer
58
views
usize - alias for max unsigned integer type, in wit
How to define usize type in a .wit file. If instead of usize, I type in u64 it works. But want to know if there is a type of max unsigned integer that matches with usize.
get-size: func() -> result&...
2
votes
1
answer
93
views
Rust WASM memory ptr is not same as JS Arraybuffer offset
I try to pass json content from js to rust with zero copy, but is seems the memory where rust vec ptr point to is not same as js arraybuffer with offset.
My Env:
cargo 1.83.0
wasm-pack 0.13.1
wasm-...
2
votes
0
answers
96
views
What is the cleanest way to re-implement Rust's BufRead, Read, and Seek traits for WASM?
I am working on a VScode extension, which uses a combination of Typescript and WebAssembly for file parsing and data handling. The parser is written in rust and compiled to WASM, as this is faster and ...
2
votes
1
answer
320
views
Rust WASM code stalls on awaiting web_sys::Window.fetch_with_request
I am trying to use the Fetch API using web_sys in Rust WASM code. I have defined an async function:
#[wasm_bindgen]
pub async fn fetch_as_vec_u8(resource_name: &str) -> Result<Vec<u8>, ...
1
vote
1
answer
1k
views
Unable to resolve wasm-bindgen dependency conflict
I'm using Tauri v2. I'm trying to add the amazing photon_rs crate for image manipulation.
When I run cargo run I can see there's a version conflict with wasm-bindgen:
Updating crates.io index
error: ...
0
votes
1
answer
165
views
Can't call function on object in javascript even though it is there
I cannot call a function on an object in javascript of a class made by wasm-pack (0.13.0), wasm-bindgen, rust.
This is the rust code:
use wasm_bindgen::prelude::*;
use web_sys::HtmlCanvasElement;
use ...
0
votes
1
answer
143
views
How can I return a tuple to javascript from wasm where elements have non Copy/Clone traits?
I have a problem where I need to return a tuple from a wasm function as the following:
#[wasm_bindgen]
pub fn channel() -> (futures::channel::mpsc::Sender<i32>, futures::channel::mpsc::...
1
vote
1
answer
293
views
How to re-initialize a module generated by wasm-bindgen?
How do I instanciate multiple wasm modules generated using wasm-bindgen?
We're using --target web, which generates a js wrapper code, which exports an "init" function using export default.
...
3
votes
1
answer
130
views
How to use string slices in Rust targeting WebAssembly
I've developped a library in Rust to parse RTF content. I've initially targeted x86 architectures. So I have use lots of string slices (&str) to reference to the original source without copying ...