mozilla / uniffi-rs

a multi-language bindings generator for rust
https://mozilla.github.io/uniffi-rs/
Mozilla Public License 2.0
2.48k stars 211 forks source link

Store return values in RustCallStatus #2157

Open bendk opened 1 week ago

bendk commented 1 week ago

FFI function calls currently use 2 methods to return results:

If we made it so RustCallStatus stored the return value as well, then it would simplify several aspects of bindings generation:

Maybe we should return the struct to RustCallResult to signify that it's also storing the return value now.

Note: if we implemented this, something similar to the void return issue would arise since C struct fields can't be zero-sized. However, there are a couple fairly simple solutions to that:

I don't think this should give us a significant performance hit, but we should measure that.