wasm-bindgen
wasm-bindgen copied to clipboard
web_sys: Dictionaries don't have getters
Describe the Bug
dictionary types from WebIDL do not have getters. You can only mutate dictionaries, and never read them. This is weird, considering how they're often used as event types or return types.
Steps to Reproduce
Example: AudioDecoderSupport has no getters, despite being defined as a return type to indicate to the caller which formats are supported. defined here has no getters
Expected Behavior
config(&self) -> AudioDecoderConfig should be a getter
set_config(&mut self, val: &AudioDecoderConfig) should be a setter
Actual Behavior
config(&mut self, val: &AudioDecoderConfig) is the only function available regarding the underlying config field, and it is a setter.
Additional Context
This is the generating code. I've dumped several hours into modifying it to generate a setter, but I've failed so far. My main issue is how do you generically convert the a JsValue from js_sys::Reflect::get into the appropriate return type? There are lots of special cases that work but it's unclear how to do this generically. E.g., how do I turn a JsValue into an Option<i32>?
Very stumped here, but willing to do work to make a PR. Please comment with pointers and I'll be on it.