284 questions
1
vote
0
answers
20
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
96
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
65
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
41
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
60
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-...
0
votes
0
answers
30
views
How to refresh a list from GET endpoint after POST request in Rust Yew
The backend on localhost:3040/todos accepts GET and POST requests. In the frontend there is a form with an input field and the submit button to send POST. Underneath the form is the list retrieved by ...
2
votes
0
answers
80
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
156
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
502
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
0
answers
54
views
How to implement HasDisplayHandle and HasWindowHandle for a HtmlCanvasElement in raw_window_handle 0.6?
How can I implement HasWindowHandle and HasDisplayHandle for a web_sys::HtmlCanvasElement?
This is what I tried, but it does not compile due to display_handle and window_handle being of wrong types, ...
0
votes
1
answer
122
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
95
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
168
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
83
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 ...
0
votes
0
answers
38
views
How do I create the input argument "Object" for read_with_array_buffer_view(&obj)?
In this case I am trying to read a small utf8 text file ( < 4k ), which I eventually want to move into a String.
let dref = jval.dyn_ref::<ReadableStreamByobReader>();
let byob_reader = dref....