Summary
What we have essentially done in this chapter is build a program that accepts some command-line inputs, interacts with a file, and edits it depending on the command and data from that file. The data is simple: a title and a status. We could have done this all in the main
function with multiple match
statements and if
, else if
, and else
blocks. However, this is not scalable. Instead, we built structs that inherited other structs, which then implemented traits.
We also defined the structure of our to-do service with workspaces. Here, we enabled our service to have multiple layers so we can swap approaches to storage easily. We also explored how to structure a basic service with a main and data access layer.
In chapter 5, we will build out our service on how to handle HTTP requests using a web framework. However, before we handle HTTP requests, we will explore async in detail, as we use async rust to handle incoming HTTP requests. Chapter 4 is an isolated chapter, meaning that you...