-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dart vdd #108
base: master
Are you sure you want to change the base?
Dart vdd #108
Conversation
CLA Assistant Lite bot All Contributors have signed the CLA. |
I have read the CLA Document and I hereby sign the CLA |
@Dampfwalze Okay, bindings should be hooked up now. Let me know if this initial implementation is ok or needs reworking 😁 A note about the under the hood
|
Some rust features cannot be bridged to Dart at the moment. These include type aliases and slices.
I made breaking changes to the bindings again. I'll fix them on this branch later today |
e0e4a69
to
440e308
Compare
I reverted the merge for now with a force push |
Should be good now. I feel like I've more or less settled on a good and robust api (though let me know if I did miss something). |
I feel like you are desperately trying to hide the tokio runtime inside your api and keeping your api synchronous. I don't think this is beneficial. It should be the responsibility of the user to provide a runtime. In fact, There are many methods which can just be asynchronious, which not only reduces complexity, but also gives the control to the user. |
Tokio is indeed an intentional implementation detail, in which the runtime was required to properly handle things for the sync api. Later on I will re-organize the API and internal code more to better reflect both cases, and in the async case, use the users runtime. When I was talking about settling on something good, I meant with the overall internal design and style of the api (not whether parts were sync or async; that's easily solvable). For example, things like, "did you need access to the monitor state but an api method to access them isn't there?" and "I want to add a mode, but the api doesn't have that function, and I'd rather not write it myself since it's such a common thing" I was not avoiding making more async methods that match their sync counterparts, or avoiding making a clear delineation between both async/sync apis. The design is after all still in flux, and is an iterative process as most things are. Did you have need for async equivalents right now? |
Related: #101
There are a few points of interest:
flutter_rust_bridge
I used a Dart feature called native-assets to build and link the Rust library, which is currently not stable and behind an experimental flag. It is essentially a
build.dart
file, similar to Rustsbuild.rs
. Traditionally, it was not possible to distribute binaries with just Dart. Flutter has its own mechanisms for this, but then, the package can only be used in Flutter projects. The native-assets feature is meant to replace these mechanisms in the future. But for now, it is only available in Flutter on themain
channel (like nightly in Rust).The API uses a Dart
Stream
as the main way of communicating the driver's state (as an immutable data structure). It would stream any changes made to the driver, regardless of who did it, so it would always reflect the correct state of the driver. This pattern is quite native to Flutter to build on top of.