I’m a Rust noob (and mostly-Python expert) attempting to write a simple CLI program in Rust as a means of getting to learn more of the language.
My question is mostly a design question, although if you are interested in some code I’ve written so far, it’s up on Github - https://github.com/yuvadm/slingr
Details aside the essence of this program has to do 3 things:
- Provide a nice CLI (which I’m mostly basing on
clap) that wraps all the user interaction
- A thread that captures user-generated keystrokes that control the program
- A thread that handles asynchronous UDP traffic (sending and receiving)
What is the best way to structure this program? I’m trying to get rid of my OOP way of thinking and use more proper Rust idioms - such as traits and
mpsc for thread communication. Ideally I’d like to have these three components separated by these lines, but I’m open to hearing other ways of achieving this.