wasm-bindgen Questions

2

Solved

I'm trying to export the following struct: #[wasm_bindgen] #[derive(Eq, PartialEq, Debug, Clone)] pub enum TokenType { KeywordLiteral, NumberLiteral, Operator, Separator, StringLiteral, } #[w...
Rojo asked 4/7, 2021 at 10:48

3

When providing callbacks to JavaScript using Closures, what's a better way to deal with avoiding freeing them? The wasm-bindgen guide suggests using .forget, but admits that that is essentially lea...
Forsythia asked 21/1, 2020 at 7:12

3

I know that wasm doesn't have blocking so how would I do the equivalent. Or is there a different tool to use? I'm new to this so it could also be that my approach is completely off. I'm using wasm-...
Fulton asked 7/6, 2023 at 2:46

1

Context I'd like to improve my understanding of memory management and the usage of function free with wasm-bindgen. My understanding is that anything allocated must be freed. In particular this sho...
Flong asked 6/2, 2023 at 17:16

1

Solved

I am trying to work out how to call a JavaScript function using Rust and wasm-bindgen. Due to lack of browser support, I cannot use wasm-bindgen with ES6 modules together with a Web Worker. As far ...
Crockery asked 7/9, 2020 at 20:2

2

Solved

Part of my Cargo.toml for my crate: [features] wasm = ["ed25519-dalek/nightly", "rand/wasm-bindgen", "js-sys"] This works, when the crate is used in another project, and the "wasm" feature is ex...
Theurer asked 17/9, 2019 at 10:29

5

I'm trying to get access to an Iterator over the contents of a file uploaded via an input field. I can pass the JS file into Wasm just fine via web-sys, but I cannot for the life of me figure out h...
Blase asked 11/6, 2021 at 23:42

3

How to convert a local closure into a js_sys::Function? I want to do something like this: let canvas = document.get_element_by_id("canvas").unwrap(); let e: web_sys::HtmlElement = canvas....
Calamity asked 4/2, 2020 at 10:4

3

Solved

I have some rust code that compiles to web assembly using wasm-pack and wasm-bindgen. I want to call into this code from a web worklet/worker. The entire app should eventually be just one single *....
Andraandrade asked 20/12, 2021 at 10:13

2

Solved

I followed the Hello World Guide for wasm-bindgen (I am using wasm-bindgen = "0.2.72"). Unfortunately the npm packages mentioned in the guide are not really up to date. Because I would li...
Ludly asked 21/3, 2021 at 16:5

1

Solved

I wrote some Rust code and compiled it with wasm-pack. I notice these free() methods in the generated .d.ts files: export class PdfDoc { free(): void; ... } PdfDoc owns a massive amount of memor...
Sateen asked 8/9, 2022 at 23:18

2

I am trying to use a rust-generated wasm module inside of my NextJs project. I am importing the wasm in the following way: import init, { tokenize } from "@/wasm/lazyjson"; const Test = ...
Twelve asked 4/7, 2021 at 13:46

1

Solved

So, I've been running out of memory with wasm/rust with +atomic flag and wanted to check how much memory is practically available. Here is my crude minimal working example that logs the memory of a...
Heartsick asked 22/5, 2022 at 5:23

0

This question is written for Yew v0.19 Asynchronous foreign JavaScript functions can be used in Rust through Closures, as the function to pass-in: #[wasm_bindgen] extern "C" { fn setI...
Expiry asked 12/7, 2022 at 20:52

1

Solved

I want to instantiate a Wasm module from inside a Wasm module, following this js-sys example. In the example, the add function is called which passes i32 parameters. I've created a hello world func...
Comate asked 14/6, 2022 at 14:14

1

Solved

I was getting into Rust and looking at these simple instructions for Yew framework (a frontend framework for Rust): https://yew.rs/docs/tutorial. I followed the instructions up until the command tr...
Philippines asked 6/5, 2022 at 19:27

1

Solved

Let's consider an example import object that looks like this: const importObject = { exampleAsyncImportFunction: async () => fs.readFile("./someExampleFile.txt", "utf-8") //...
Theodor asked 22/2, 2022 at 8:10

1

I'm trying to adapt the game of life tutorial to call user-defined JS (instead of alert) from Rust: index.js: import * as wasm from "testing-wasm"; export const jsfunc = () => { cons...

0

I made a benchmark to measure how fast it is to call DOM APIs by passing DOM objects as exnternrefs to a Wasm function. This is the function to measure (written in Rust and compiled by rustc 1.55.0...
Technical asked 12/11, 2021 at 13:18

1

I get the following error message: error[E0463]: can't find crate for `core` | = note: the `wasm32-unknown-unknown` target may not be installed error: aborting due to previous error For more in...
Arnone asked 9/6, 2021 at 6:4

1

Solved

I have a crate lib that contains tons of structs and impls. Then I have another one called web that will make the portability of the core lib to the web. There is also api in case I want the app to...
Constantine asked 17/12, 2020 at 0:9

1

Solved

I'm trying to use the Web3 JavaScript library from Rust and I'm stuck. The standard usage of the library starts with: // In Node.js use: const Web3 = require('web3'); let web3 = new Web3(Web3.give...
Antin asked 16/11, 2020 at 1:43

1

Solved

I'm working through the Rust WASM tutorial for Conway's game of life. One of the simplest functions in the file is called Universe.render (it's the one for rendering a string representing game stat...
Essential asked 23/10, 2020 at 21:51

1

Solved

I have a Vec I would like to return and convert to a typed array with wasm-bindgen, ie, to turn a Vec<u32> into a Uint32Array. From my research it appears that wasm-bindgen cannot handle auto...
Ita asked 20/10, 2020 at 23:19

2

Solved

My rust program is managing memory for a 2d html canvas context, and I'm trying to hit ~60fps. I can calculate the delta between each frame easily, and it turns out to be roughly ~5ms. I'm unclear...

© 2022 - 2024 — McMap. All rights reserved.