Description
0.2.88
automatically derives TryFrom
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 the TryFrom
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 between JsValue
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 custom Clone
trait, preventing the developer from being able to implement custom Clone
functionality for his objects...
Perhaps there should be a FromJsValue
derive macro available? Or such conversion should be moved into a custom try_from_js_abi()
function implemented on each ABI-bound object? (implementing a function will create much less of a potential interference with underlying frameworks).