cliserver_rust: Learning Rust by reimplementing cliserver with Tokio

Tasks to port cliserver

Lately I’ve been reading about the Rust programming language, just for fun. One of the ways I (and others) enjoy learning a new language or framework is porting an old project into the new language, while trying to take advantage of the language’s features.

So to learn Rust, I’ll be reimplementing my old cliserver example for libevent using Rust’s Tokio crate. At the risk of public embarrassment, I will be tracking my progress using GitHub issues.

The cliserver concept is pretty simple. It’s a network service that accepts raw TCP/IP connections (think netcat, not telnet) and presents a command-line interface with a few simple commands. The essential feature of cliserver is support for multiple concurrent clients, each able to run any of the supported commands with minimal interference from other clients. This basic pattern was used to develop the low-level interface protocols for my Depth Camera Controller and Automation Controller products.

Each connected client can run the following commands on a cliserver implementation:

  • echo – Print the command line.
  • help – Print a list of commands and their descriptions.
  • info – Print connection information.
  • quit – Disconnect from the server.
  • kill – Shut down the server.

You can follow along at the cliserver_rust repo.

Later and time permitting, I’m probably going to repeat the same process to learn Scala and Finagle. At that point I hope to write another blog post about the event reactor pattern in general, and how each implementation (libevent+C, Tokio+Rust, and Finagle+Scala) compares.