In the previous counter app, we had a purely sequential blocking application. There are times when
you may be interested in running IO operations or compute asynchronously.
For this tutorial, we will build a single file version of an async TUI using
tokio. This tutorial section is a simplified version of the
async ratatui counter app.
Here’s an example of the Cargo.toml file required for this tutorial:
Let’s take the single file multiple function example from the counter app from earlier:
Tokio is an asynchronous runtime for the Rust programming language. It provides the building blocks
needed for writing network applications. We recommend you read the
Tokio documentation to learn more.
For the setup for this section of the tutorial, we are going to make just one change. We are going
to make our main function a tokio entry point.
Adding this #[tokio::main] macro allows us to spawn tokio tasks within main. At the moment,
there are no async functions other than main and we are not using .await anywhere yet. We will
change that in the following sections. But first, we let us introduce the Action enum.