Replies: 2 comments
-
@neilisaac I would be happy to combine the effort for idiomatic rust bindings. I've chosen a different approach with the I think your approach might be a bit faster but it was quite easy to create the FFI abstraction. Most of the work on the current bindings was done on the idiomatic interface. What I can tell from the code snippet is that your bindings are untyped, contrary what I've done so far. I think that it would be valuable to have both. It would be great to have a look at what you already did and even it we decide to use the C++ API directly, I'm sure there would be some ideas we could borrow. Is there a chance for you to take part in one of our developer meetups? |
Beta Was this translation helpful? Give feedback.
-
The rust-binding based on bindgen has been talked about in #879 Thanks. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, as I alluded to in eclipse-iceoryx/iceoryx-rs#1, I'm working on Rust bindings for IceOryx using bindgen rather than rust-cpp.
This design provides RAII struct wrappers for each object, but is conceptually 1:1 with the C bindings to make it easy to understand.
It uses a "-sys" crate containing the bindings generated by bindgen for compatibility with cargo as well as other builds systems (bazel with rules_rust in particular).
Here is a working example of these Rust bindings. My bindings currently support almost all IceOryx v1 C functions.
To give an idea of the API, here are the publisher functions:
For the Listener callbacks, I'm storing boxed closures to share thread-safe state with the callbacks.
WaitSet and UserTrigger are mostly 1:1 with the C API. It writes into a NotificationBuffer which is backed by a fixed-capacity vec and exposes an iterator to consume NotificationInfo (a trivial wrapper around iox_notification_info_t).
I would welcome any comments or potential issues you see, and would consider open-sourcing this work if there's interest from the core developers. If there's still more interest in building directly off the C++ API, I totally understand and am happy to at least share ideas/learnings.
Beta Was this translation helpful? Give feedback.
All reactions