Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web_sys: Dictionaries don't have getters #2921

Open
rozbb opened this issue Jun 1, 2022 · 0 comments
Open

web_sys: Dictionaries don't have getters #2921

rozbb opened this issue Jun 1, 2022 · 0 comments
Labels

Comments

@rozbb
Copy link
Contributor

rozbb commented Jun 1, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant