fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.12k stars 283 forks source link

`SyncReturn` should be transparent #881

Closed ngasull closed 1 year ago

ngasull commented 1 year ago

In many scenarios async return is overkill and create a lot of complexity:

Async can be unnecessarily painful, especially when working hand in hand with flutter build functions.

Moreover, this is an opportunity to simplify the code base significantly and facilitate maintainability.

Describe the solution you'd like SyncReturn should be transparent and support anything that would be returned otherwise (probably IntoDart).

Is there a drawback or any reason why SyncReturn is serialized to bytes so far?

Describe alternatives you've considered I tried working with current implementation, working around with sync pointers or async structs, but I eventually figured I'd make a better use of my energy working on the bridge directly, which I did.

You can find here my current work on it

If my suggestion is not acceptable for some reason (transparent SyncReturn), feel free to explain me why :)

Additional context I'm so happy that such a project exists and that it is active, thank you ❤️ it will be a pleasure to help as well.

welcome[bot] commented 1 year ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 1 year ago

In many scenarios async return is overkill and create a lot of complexity

Totally agree :)

Is there a drawback or any reason why SyncReturn is serialized to bytes so far?

Because SyncReturn needs somehow a different mechanism than async return, so it is like this currently. However, surely, feel free to implement more complicated approaches, which should be great!

By the way, async is also quite useful in some scenarios: https://cjycode.com/flutter_rust_bridge/feature/async_dart.html

I tried working with current implementation, working around with sync pointers or async structs, but I eventually figured I'd make a better use of my energy working on the bridge directly, which I did. I'm so happy that such a project exists and that it is active, thank you ❤️ it will be a pleasure to help as well.

You are welcome and looking forward to your PR!

You can find here my current work on it: (link will be pasted after issue is created)

👀

ngasull commented 1 year ago

Added the link to the PR in the issue.

By the way, async is also quite useful in some scenarios: https://cjycode.com/flutter_rust_bridge/feature/async_dart.html

Of course yes! I absolutely won't minimize your great work and how useful function calls as async task executions are!

However, surely, feel free to implement more complicated approaches, which should be great!

Simple note about me: fighting against complexity is basically the story of my developer's life, so I hope you don't find my changes complex :)

And many thanks for your hospitality!

fzyzcjy commented 1 year ago

You are welcome! Cannot wait to review and merge your PR :)

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.