Does anyone have thoughts about how mature Zngur/CXX/etc. are for a project like mine? Would it be reasonable to invest effort in creating those bindings? Thanks.
At this point I have a Claude project set up with Cxx documentation and it autogenerates most of my bindings.
I'm a fan of QML and would love to use Rust with it if pleasant Qt bindings are finally there.
I haven't really used it, but it seems to use the same idea, except it's native to Rust but comes with its own C++ and JavaScript bindings. I believe the project was started by some folks that left Qt (or some company that held the IPR at some point..).
It's definitely something that looks promising, though. Hope to replace Qt with it in the future if it works out.
Writing models has been surprisingly easy but there are still lots of annoyances like having to use QVariant to store everything because properties that refer to other QObjects must be raw *mut pointers. It's only taken a few hours each to write my models including a filesystem tree model. At this point I've got several examples of Rust models and C++->Rust conversions that I feed to Claude and it can easily write models from scratch or convert C++ models in the wild to custom Rust ones.
Sadly I haven't taken notes (I should) on my experience so far so my thoughts are rather disorganized. All that said, I've got instant hot reload of all the QML bits and I don't have to write C++ code with complex lifetimes so overall it's been a win.
So, Zngur allows you to use arbitrary Rust types in C++, store them by value in the C++ stack, and call arbitrary Rust methods and functions on them. But it doesn't bridge any C++ type into Rust, since it is not possible with the same ergonomic
You want to use C++ libraries from Rust. This only does interop the other way.Unfortunately it chooses to just assume your C++ is sound, it does explicitly warn you that you're signing up for this, but realistically this just doubles down on the known bad assumption in C++ that programmers are infallible.
Rather than (like Rust's native C FFI) marking the arbitrary C++ as unsafe, Zngur chooses to have you explicitly opt in if you want your code marked unsafe. We know from years of practical experience that C++ programmers rely heavily on unstated assumptions for the correctness of code, a practice which does not scale. A very large proportion of the C++ stdlib itself has a narrow contract, yet few practitioners memorise these contracts and they're unchecked - disaster looms.
https://hkalbasi.github.io/zngur/tutorial.html#calling-c-fro...
It sound like your quoted text is just saying that it’s not as ergonomic, you cannot use arbitrary C++ types directly in Rust, but you can use arbitrary Rust types in C++.
If you want to immediately use a C++ library in Rust with minimal manual effort, check out autocxx [0]. Its generated api isn't very idiomatic Rust, and it uses Pin, moveit, ... but it covers a good percent of C++ apis and you can also make an idiomatic wrapper for it in Rust.