Rust/wasm: construct a value of type map, where keys = string, value = SharedArrayBuffer

I would like to, in Rust/wasm, construct a JS value that is an object/map where

  • key = string
  • value = SharedArrayBuffer

i.e. something like:

{ "foo": shared_array_buffer_1,
  "bar": shared_array_buffer_2 }

I am looking at JsValue in wasm_bindgen - Rust and it is not obvious to me how to construct this.

Is there a way to do this ?

didn't realize we still need to use Reflect for this:

1 Like

Thanks, would not have guessed js_sys::Reflect::set , or that js_sys::Object derefs to JsValue.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.