I wrote a status bar generator to learn async Rust, and Rust continues to amaze me

45 points NoLemurs

You can see the source code here. It's a tool for generating status bar output for text-based status bars like dzen2, xmobar, or lemonbar. Feedback welcome!

I've been programming in Rust a lot lately for hobby projects, but have a lot more experience working with Python, Typescript, and C++. There is zero chance I could have written anything half as reliable and correct any of those languages even given twice the time.

Highlights:

  • Between tokio and futures I was able to write an event based system to handle data from any number of sources that was concise, efficient and easy to reason about.
  • Rust bindings on low-ish level libraries like rtnetlink or libpulse-binding made it possible for me to discover and use the APIs mostly by looking at the types exposed on docs.rs. I shudder at the thought of trying to handle netlink messages without Rust's help.
  • The borrow checker prevented me from making a ton of mistakes while implementing the pulse audio volume monitor. In C++ my code would have had some serious bugs, it would have taken me days to fix them, and I never would have been very confident I was doing it right. Pulse audio is complex and unforgiving, but Rust made it manageable.
  • serde + toml made writing and parsing complicated config a joy.

I expected writing this in Rust to be a good experience, but I'm still shocked by just how easy it was. I've got exactly the program I set out to write, it works really well, and about the only downside is that I want to keep fiddling, but the program is pretty much just done. I've got nothing left to fiddle with!