uniffi-rs
uniffi-rs copied to clipboard
New system for remote / custom / external types
As discussed in #1865, this is how I think we should update our code for remote / custom / external types.
The doc changes are the first commit so that we can agree on how things should work from the user's perspective.
Changes:
- Make remote types a first-class feature.
- Make UDL generate blanket ffi trait impls for all UniFfiTags. Remove the
use_udl_*since we don't need them anymore. - Add
use_remote_type!to handle the one case where we do need to forward ffi traits impls to another crate's tag. - Use a macro to define custom types. This way we have more freedom to change how things are implemented behind the scenes.
- Update the UDL external syntax so that
[Extern]can work with any type.
Benefits are:
- UDL and proc-macros will be consistent in their handling of UniFfiTag.
- First-class remote types would enable things like using anyhow::Error in interfaces.
- The custom type macro is easier to use then the current code. It's also easier for us to make changes behind the scenes.
- External types get a little less hacky.
- 3rd party crates can provide built-in UniFFI support and implement the ffi traits for all their consumers.