-
Notifications
You must be signed in to change notification settings - Fork 0
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
consider FFI bindings #2
Comments
I've been exploring cbindgen to create a C binding from rust source. Unfortunately, I'm withdrawing the C binding from this proposal because cbindgen is rather limited. It cannot bind functions that use optional parameters, and function parameters cannot be given a default value. This affects
Luckily, we already have a seasoned C++ code base for the nRF24L01 😉. And, I doubt anyone would want to migrate away from that just for memory safety. |
About jni-rsjni-rs is looking for new/more maintainers. This isn't a good sign for those of us wishing to use it in production-grade code. At first glanceI'm not sure how a java class translates to a rust struct. None of the examples for jni-rs demonstrate this. All of the examples simply use a java class as a namespace for static methods (which are implemented in rust). Full disclosureI don't have any experience writing java. I'm not sure java has any significant following in the embedded dev sphere. I'm leaving the java binding in this proposal to be considered optional. If we have a request to add it, then I'll reassess. |
GO bindingI also looked into a GO language binding, but that seems dependent on a project named CGO; this would require translating rust into a C binding, and then linking the GO code to the exported C symbols. From what I can gleam (I'm no well versed in GO), there's virtually no benefit from writing GO implementations in rust because both languages seem to offer similar guarantees (memory safety with strict typing). Instead, it would just be better/easier to write an implementation in pure GO because there is a specialized GO compiler for embedded development: tinyGO. Dart bindingIf someone wants to write a flutter app using the nRF24L01, then theoretically, they could just use this rust package with the PS - Cross-compiling Dart isn't really possible (without Docker containers and/or Virtual Machines), and it doesn't seem to be a goal for the Dart team. |
It occurred to me that we could generate bindings using the same rust code base for
C (cbindgen for bindings and <your-choice-here> for packaging like conan or vcpkg or both and more)The python, node.js, and java bindings would only work for Linux (32 or 64 bit).
I haven't explored the C or Java ideas, just throwing that out there. I have been exploring the python and node ideas (in a different project).
To use C bindings in Arduino builds, we'd have to ship the library with generated header file(s) and pre-compiled binaries (
*.a
files compatible with any supported architectures -- mostly variations of arm-none-eabi for newer chips). But I'm not sure how feasible that would be, given complications like an RTOS or other multi-tasking implementations.The text was updated successfully, but these errors were encountered: