Closed felixSchl closed 1 week ago
Hi! Thanks for opening your first issue here! :smile:
Hi, it seems that you type is not Send, while it is needed for frb because there can be multiple threads.
Is there any way to get this working? I don't need to interact with the engine field from flutter. I really just need an opaque top-level handle to the MyStruct instance living in rust land.
One way is to use a single-thread event loop, such that that object always live in one single thread. I may add a feature to make this automatically integrated (currently you need a few lines to wrap it).
Thank you. I would love to learn more about how to do this manually and what this would imply. I am not using any async code in rust.
If you are not urgent, maybe wait for 2-3 days, since I will be likely working on it. Feel free to ping me if there is no new version within days. Or if you are urgent, just ask now!
There's really no urgency on my part. I have plenty of other work I can circle back to in the meanwhile. I am mostly just curios.
Btw, maybe it is possible to make the rhai type Send
(e.g. ask there)? Because I checked https://github.com/rhaiscript/rhai briefly, and it seems that there may not be special things to avoid it being Send.
If so, then we can simply wrap with a tokio Mutex
to make it Sync, and everything goes well.
Ok there is:
https://github.com/rhaiscript/rhai
Re-entrant scripting engine can be made Send + Sync (via the sync feature).
Maybe enable that flag and it will work!
Thank you! That did indeed do the trick 👍💯
You are welcome!
Describe the bug
I am trying to expose a handle to a rhai Engine to dart, but I cannot get it to work. I am getting ~70 errors and they all read like this
Steps to reproduce
Example code (requires
rhai
create to be installed)Logs
OS
No response
Version of
flutter_rust_bridge_codegen
No response
Flutter info
No response
Version of
clang++
No response
Additional context
No response