This adds a binding for UniFFI to dart the language used by flutter.
This is a work in progress and should not be trusted.
Please contribute to the dart bindings!
Use the tool as usual and use the dart language argument during the build --language dart
.
- It seems that foreign callbacks are not fully supported in dart yet as we can't return a value. Uniffi expects a return int.
- Checking the methods checksums in the binding file and the binary.
- Not everything can write back to the buffer (enums).
- Testing
- And more! (Please contribute!)
The following README is from the original repo
UniFFI is a toolkit for building cross-platform software components in Rust.
By writing your core business logic in Rust and describing its interface in a special interface definition file, you can use UniFFI to help you:
- Compile your Rust code into a shared library for use on different target platforms.
- Generate bindings to load and use the library from different target languages.
For example, UniFFI is currently used in the mozilla/application-services project to build browser storage and syncing functionality for Firefox mobile browsers. Core functionality is written once in Rust, and auto-generated bindings allow that functionality to be called from both Kotlin (for Android apps) and Swift (for iOS apps).
Currently first-party supported foreign languages include Kotlin, Swift, Python and Ruby. Additional foreign language bindings can be developed externally and we welcome contributions to list them here. See Third-party foreign language bindings.
You can read more about using the tool in the UniFFI user guide.
Please be aware that UniFFI is being developed concurrently with its initial consumers, so it is changing rapidly and there are a number of sharp edges to the user experience. Still, we consider is developed enough for production use in Mozilla products and we welcome any feedback you may have about making it more broadly useful.
ˈjuːnɪfaɪ. Pronounced to rhyme with "unify".
A portmanteau word that also puns with "unify", to signify the joining of one codebase accessed from many languages.
uni - [Latin ūni-, from ūnus, one] FFI - [Abbreviation, Foreign Function Interface]
Other tools we know of which try and solve a similarly shaped problem are:
(Please open a PR if you think other tools should be listed!)
- Kotlin Multiplatform support. The repository contains Kotlin Multiplatform bindings generation for UniFFI, letting you target both JVM and Native.
- Go bindings
- C# bindings
There are a few third-party resources that make it easier to work with UniFFI:
- Plugin support for
.udl
files for the IDEA platform (uniffi-dl in the JetBrains marketplace). It provides syntax highlighting, code folding, code completion, reference resolution and navigation (among others features) for the UniFFI Definition Language (UDL). - cargo swift, a cargo plugin to build a Swift Package from Rust code. It provides an init command for setting up a UniFFI crate and a package command for building a Swift package from Rust code - without the need for additional configuration or build scripts.
(Please open a PR if you think other resources should be listed!)
If this tool sounds interesting to you, please help us develop it! You can:
- View the contributor guidelines.
- File or work on issues here in GitHub.
- Join discussions in the #uniffi:mozilla.org room on Matrix.
This project is governed by Mozilla's Community Participation Guidelines.