
Understand how this series will help you learn to use the tools in the Rust ecosystem effectively.
• Introduce Rust as a language and its growing ecosystem.
• Get an overview of the course
• Get introduced to the teacher
Every program needs to have a clean and consistent user interface. clap can help us provide that.
• Make sure Rust is installed
• Use Cargo to import clap
• Build a program that outputs its version and a help message
This video shows how we can convert markdown into HTML.
• Introduce and import pulldown_cmark
• Parse the chosen file
• Print the file to stdout
How can we create new build clear HTML from within Rust?
• Introduce and import Maud
• Introduce and install nightly Rust
• Build a Maud template into our program
How can we let other people use our application?
• Get a crates.io account
• Make sure our crate is ready
• Publish the crate
How can we use the regex library to check the contents of a file?
• Introduce the regex crate
• Use the crate to parse a file
• Test a file for the given content
Is there a unified way of handling errors or different types?
• Introduce the failure crate
• Show how type can implement the Fail trait
• Show how that enables us to use the ‘?’ operator
Can we make our error types implement Fail, without large amounts of boilerplate code?
• Introduce the derive Fail macro
• Show how Fail display can be implemented in a macro
• Reduce our Fail code
Can we handle errors without ending the program, yet still show the user all the errors that occurred?
• Search multiple directories recursively
• If a directory has an error, leave it, but search the rest
• Make sure all errors are shown to the user
How can we allow our program to keep working even while its waiting for something?
• Introduce futures
• Show how futures are simply a trait
• Introduce the poll function
How can we communicate between futures?
• Introduce MPSC channels
• Show how we can send data to our channels
• Show how we can us loop to and return to wait for a channel
How can we run two futures at the same time?
• Show how tokio::run runs a future to completion
• Use the lazy function to build a future, that spawns both futures
• Call tokio::run on the lazy future
How can we ask for information from another future?
• Introduce the one-shot channel
• Send a one-shot channel down an MPSC channel
• Use the one-shot receiver as a future on its data
How can we get data back out of our futures, once they have completed?
• Create an MPSC channel outside of the futures’ scope
• Send our results into the MPSC, during the futures
• Call ‘wait’ on our MPSC outside the futures, to turn it into an iterator
How can we get data out of a reader without blocking our code?
• Introduce AsyncRead
• Create a Stream struct that will read the AyncRead
• Return a Stream of strings
How can we write to a writer without blocking from multiple places?
• Introduce AsyncWrite
• Create an MPSC channel for writing to
• Iterate the channel inside a futures loop
How can we listen for TCP connections and handle the requests?
• Introduce the TcpListener
• Bind it to an address
• Use for_each on the incoming stream of connections
How can we convert our data into a Rust type?
• Introduce Serde
• Create a struct that implements deserialize
• Use serde_json::from_str to parse our type
How can we make a complete chat application using these things?
• Import our chatbox
• Send our messages to the chatbox
• Push the results of this to our AsyncWrite based future
In order to store data, we need to have a database to connect to.
• Install PostgreSQL database
• Login to PostgreSQL
• Create new databases and tables within PostgreSQL
In this video, we shall connect Diesel to the database.
• Install the Diesel command line interface
• Connect it to PostgreSQL
• Get Diesel CLI to create a new database
How can we build our database structure in a way that is easy to replicate, and access in a type-safe way from Rust?
• Introduce the concept of migrations
• Show how migrations can change your database over time
• Create a new migration for a list of shop items
How can we add data to the database?
• Create a database connection
• Show the methods that create the query
• Run the query
How can we re-read data from the database?
• Introduce the common read methods
• Implement one to get a list of items matching a query
• Print the results
How can we update a record without data being overwritten while we update?
• Read the data with a FOR UPDATE lock
• Edit the data
• Write the data, releasing the lock
How can we build a web facing application simply?
• Introduce Actix and Actix web
• Build an Actix server
• Attach that server to some static files
How can we make our website access data from our database?
• Introduce responders
• Build a responder that connects to the database
• Return a JSON file with the requested data
Diesel is not asynchronous, but in order to run a fast website, we need to make our connections to it work asynchronously.
• Build an actor that receives and responds to messages
• Connect that actor to the database
• Make our server send and receive messages, from the actor asynchronously
Can we access lots of data from the request in a more scalable way?
• Introduce extractors
• Adapt our server functions to receive extractors instead of the request
• Handle the data from the extractors directly
Can we output our data in a more user-friendly way?
• Introduce templates
• Show how we can use lazy_static to load all our templates exactly once
• Render our templates with data from the response
Can maintain data across multiple sessions?
• Introduce middleware
• Show how we can read and edit session data
• Add the middleware to our app to make sure our session stays valid
In this video, we will have a look at what we learnt throughout this course.
The Rust programming language is a boon for systems programmers because of its powerful and expressive type system and strict compile-time static analysis. Still, there are best practices to follow and idioms that the community has developed over time. This course tackles testing, building and distributing applications, and other real-world challenges using Rust, Cargo, and the Rustup toolchain manager.
You will build four projects, including a search tool, a Markdown parser, a chat server and client, and a blog. In this course, we’ll progress from command line applications, built with proper command line argument parsing and error handling, to more complex applications like a GUI text editor and several web applications. We’ll explore asynchronous programming and concurrent programming in Rust using real-world scenarios like file searching and stress testing. Finally, we’ll build a simple web app that interacts with a database in a type-safe manner using Diesel.
By the end of the course, you will be adept with the knowledge of Rust to practically implement it in real-world projects. You’ll know enough to build high-quality software that can be shared with the rest of the Rust community or even used in production.
About the Author
Matthew Stoodley is a programming expert and enthusiast and was drawn to learn about Rust and master its features initially due to its low power usage and memory safety capabilities. He primarily uses Rust to build board games. In addition, he also possesses several years of experience in Go, PHP, and JavaScript among many others.