jhugman / uniffi-bindgen-react-native

A uniffi bindings generator for calling Rust from react-native
Other
0 stars 0 forks source link

Implement UniffiTraits for Objects #51

Closed jhugman closed 1 month ago

jhugman commented 1 month ago

UniffiTraits are a handful of utility traits that Rust can implement automatically.

If a UniffiTrait is implemented, then the expected behaviour is that the foreign language forwards calls on to Rust.

e.g. adding #[uniffi::export(Display)] causes a toString() method to Javascript.

Unfortunately, the corresponding methods in Javascript are all non-standard.

I feel sure that there valueOf() and [Symbol.toPrimitive] may be useful to implement here, but I don't know enough about the internals to be sure this is the right thing to do.