Questions tagged [web-sys]

22 questions
0
votes
0 answers

Borrow non-'static data in future with wasm_bindgen_futures

I am launching multiple threads from incoming tcp connections which need to read from a file or anything that implements the std::io::Read and std::io::Seek trait. I have the following working implementation (1): fn upload
Kevin
  • 3,096
  • 2
  • 8
  • 37
0
votes
1 answer

Get parameters from web_sys::File in rust

I'm sending a FileList from JavaScript and trying to read the parameters of the specific file from the list, like the file name but I'm getting the error:method not found in Option (I'have tried different variants to call the getter…
Sheki
  • 1,597
  • 1
  • 14
  • 25
0
votes
1 answer

Create web_sys::RtcPeerConnection with customized configuration

I am trying to figure how to create a RtcPeerConnection with the web-sys crate. In JavaScript I can write the following: const pc = new RTCPeerConnection({'iceServers': [{'urls': ['stun:stun.l.google.com:19302']}]}); How does this translate to…
Kevin
  • 3,096
  • 2
  • 8
  • 37
0
votes
1 answer

Converting Vec into JsValue

I am trying to define a js_sys::Promise. The resolution of the promise should return a container buf with all gathered ice candidates in a webrtc initialization. let promise = js_sys::Promise::new(&mut |resolve: js_sys::Function, reject:…
Kevin
  • 3,096
  • 2
  • 8
  • 37
-1
votes
1 answer

How to get window.ethereum in web_sys()?

In javascript to connect metamask it uses window.ethereum if (window.ethereum) { window.ethereum .request({ method: "eth_requestAccounts" }) .then((res) => accountChangeHandler(res[0])); } else { alert("install…
Amiya Behera
  • 2,210
  • 19
  • 32
-1
votes
1 answer

after using move in closure I got "cannot infer an appropriate lifetime due to conflicting requirements "

my struct use web_sys::{Document, Element, window}; use wasm_bindgen::{UnwrapThrowExt, JsCast}; use std::cell::RefCell; use wasm_bindgen::closure::Closure; use web_sys::console::log_1; pub struct Draggable2 { doc: Document, pub(crate)…
Ali Husham
  • 816
  • 10
  • 31
-2
votes
1 answer

How to add an event listener to some HTML element from Rust which calls a trivial JS function?

I have the "on_event" JS function: function on_event(event) { console.log(event); } And I have the "button" HTML element builder in Rust: let window = web_sys::window().expect("no `window` object"); let document = window.document().expect("no…
Nick Nizovtsev
  • 233
  • 1
  • 10
1
2