Does anyone have experience of creating a GUI for an embedded system in Rust? Which crate would you recommend?
One more question:
Am I right in thinking that all existing GUI crates use dynamic allocation, making them unsuitable for safety-critical applications?
Depending on what the device is, one of the approaches would be to use "external" GUI and put a server crate into device itself. To stay more on the Rust side, a web application served for device interface can be written in Webassemly. The system I wrote this way is not embedded, but I also know that putting a dedicated screen, keyboard on something that otherwise can just be a box is often troublesome.
Something "without dynamic allocation" sounds really special. No heap? No Vec, no HashMap, not even String? It must be specially written, no generic GUI crate would do.
It appears to have an open-source option as well, licensed under the GPL. This way, using it for your own hobby project should be no problem, and if you want to make a big business out of it later, a commercial license can likely be purchased at that time. However, I have some doubts about whether it is truly heap-free.
There's ratatui that's a TUI (rendering a "GUI" into a terminal) and works without Rust's standard library (no_std), but it still requires dynamic allocation:
Lack of any dynamic allocation is extremely limiting for a general-purpose GUI framework. Maybe you could DIY something using:
There is embedded_graphics - Rust, but it is a bit low level. For something like a "UI framework" there currently are no really good solutions, without allocations. But, there are two small projects I know of and we are using one of them on some subset of our hardware. They don't allocate too.
One we use is buoyant - retained mode ui, you write functions that return impl View and compose then together, there is a book too. Another one is kolibri, immediate mode ui, but developer seems to have lost the interest. I personally think that imgui is better suited for embedded, but, well, buoyant is quite cool too, supports animations, layouts and stuff, just the structs would eat a little bit of RAM, without dynamic allocations. We usually use TAIT to put stuff like that into static.
We also used lvgl, but lvgl - Rust bindings are both unsound and hard to use, as well as allocate A LOT. A LOT.
For that ratatui, I didn't read much into it's source code, but I have a feeling it will allocate a lot too.