-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Include Record Type #3587
Comments
It seems like #[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = Object)]
pub type GpuDeviceDescriptorRequiredLimits;
#[wasm_bindgen(method, indexing_setter)]
fn add_entry(this: &GpuDeviceDescriptorRequiredLimits, key: &str, value: f64);
}
impl GpuDeviceDescriptorRequiredLimits {
pub fn new() -> Self {
Object::new().unchecked_into()
}
pub fn entry(&mut self, key: &str, value: f64) -> &mut Self {
// alternatively this could use `Reflect::set`
self.add_entry(key, value);
self
}
} |
Considering how using a builder-style API for dictionaries didn't turn out so well, I would prefer not to repeat this mistake. Especially the whole Happy to review a PR adding this! |
Motivation
In the
GpuDeviceDescriptor
generated struct inweb_sys
, we don't get access to therequired_limits
api since it has a WebIDL type ofrecord<DOMString, GPUSize64> requiredLimits;
. The relevant piece of code which omits therecord
type is here.WGPU needs access to this particular field to be able to request a device with limits other than the bare minimum.
Proposed Solution
A kind of
Record
type added intojs_sys
, since it seems that the blocker (reasonably) is the lack of aRecord
type injs_sys
. Exactly how this would look is something I'm not sure, hence why this is an issue and not a PR, and am welcoming discussion.Alternatives
We could also simply ignore the type constraints we are supposed to follow for
record
types and allow any keys. However, this would be unwanted since you could get silent or cryptic errors since the api you are communicating with may recieve unexpected types as the keys.The text was updated successfully, but these errors were encountered: