-
-
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
0.2.88 implements TryFrom on all ABI-bound objects, breaking API bindings that have custom TryFrom implementations #3685
Comments
+1 it should be gated by feature or attribute |
I think the solution here is to create a new (internal?) trait or function instead of using But I agree this is an issue and we should fix that. |
0.2.88 is already out, so it'd be a breaking change to remove the automatic
Yeah, an internal trait is the way to go if we want |
It should be an opt-in as opposed to opt-out. Or gated by a feature, disabling all related functionality. The breaking changes were introduced by 0.2.88 to like 15+ published downstream crates (at least on our end across different projects). For access you can impl a custom fn on the struct like ref_from_abi(JsValue) -> Option<&..> |
We could yank 0.2.88. As I understand it, the automatic |
I think the nicest thing would be to create a And I don't think we should yank |
I do believe that adding the
That would be the solution indeed. That said, I'm not sure if all this is really necessary. I don't get the impression that this has caused a widespread issue, though considering the lack of data I might also be totally wrong on that. If somebody pushes this to happen and makes a PR fixing this, by implementing a new trait like the Let me know what everybody thinks about that. |
I will do it |
This commit replaces the usage of the standard library's TryFrom trait with a custom TryFromJsValue trait added for handling the conversion from JavaScript values in WASM. This trait has been implemented for different types across multiple modules to ensure consistent error handling on failed conversions. fixes rustwasm#3685
This commit replaces the usage of the standard library's TryFrom trait with a custom TryFromJsValue trait added for handling the conversion from JavaScript values in WASM. This trait has been implemented for different types across multiple modules to ensure consistent error handling on failed conversions. fixes rustwasm#3685
This commit replaces the usage of the standard library's TryFrom trait with a custom TryFromJsValue trait added for handling the conversion from JavaScript values in WASM. This trait has been implemented for different types across multiple modules to ensure consistent error handling on failed conversions. fixes rustwasm#3685
This commit replaces the usage of the standard library's TryFrom trait with a custom TryFromJsValue trait added for handling the conversion from JavaScript values in WASM. This trait has been implemented for different types across multiple modules to ensure consistent error handling on failed conversions. fixes rustwasm#3685
0.2.88
automatically derivesTryFrom
trait for any struct that uses#[wasm_bindgen]
.This prevents any developer from creating custom
TryFrom<JsValue>
conversions for the ABI-bound struct.We have a rather large Rust/JS API that uses
TryFrom
to provide custom processing for JS objects. For example, JS code can pass a Rust struct, a buffer, or a hex string, which theTryFrom
resolves. This is extremely useful because JS objects can be of different types. The object received from JS does not need to be an ABI-bound object in order to be converted to a native Rust struct.This addition makes it no longer possible to create custom
TryFrom
handling betweenJsValue
and a Rust struct that is also WASM ABI-bound.I believe that such imposition should not be present in the attribute macro, or it should be possibly gated by a feature or a macro attribute. It does not seem quite right that an attribute macro creates functionality that is typically created by derive macros.
This is semantically not different than (for example)
wasm_bindgen
implementing a customClone
trait, preventing the developer from being able to implement customClone
functionality for his objects...Perhaps there should be a
FromJsValue
derive macro available? Or such conversion should be moved into a customtry_from_js_abi()
function implemented on each ABI-bound object? (implementing a function will create much less of a potential interference with underlying frameworks).The text was updated successfully, but these errors were encountered: