Book Image

Creative Projects for Rust Programmers

By : Carlo Milanesi
Book Image

Creative Projects for Rust Programmers

By: Carlo Milanesi

Overview of this book

Rust is a community-built language that solves pain points present in many other languages, thus improving performance and safety. In this book, you will explore the latest features of Rust by building robust applications across different domains and platforms. The book gets you up and running with high-quality open source libraries and frameworks available in the Rust ecosystem that can help you to develop efficient applications with Rust. You'll learn how to build projects in domains such as data access, RESTful web services, web applications, 2D games for web and desktop, interpreters and compilers, emulators, and Linux Kernel modules. For each of these application types, you'll use frameworks such as Actix, Tera, Yew, Quicksilver, ggez, and nom. This book will not only help you to build on your knowledge of Rust but also help you to choose an appropriate framework for building your project. By the end of this Rust book, you will have learned how to build fast and safe applications with Rust and have the real-world experience you need to advance in your career.
Table of Contents (14 chapters)

Understanding the MVC architectural pattern

This chapter is about creating web apps. So, to make things more concrete, let's look straight away at two toy web applications named incr and adder.

Implementing two toy web apps

To run the first toy application, let's take the following steps:

  1. Go into the incr folder and type cargo web start.
  2. After a few minutes, a message will appear on the console, ending with the following line:
You can access the web server at `http://127.0.0.1:8000`.
  1. Now, in the address box of a web browser, type: 127.0.0.1:8000 or localhost:8000, and immediately you will see the following contents:
  1. Click on the two buttons, or select the following textbox and then press the + or the 0 keys on the keyboard.
  • If you click once on the Increment button, the contents of the box to the right change from 0 to 1.
  • If you click another time, it changes to 2, and so on.
  • If you click on the Reset button, the value changes to 0 (zero).
  • If you select the textbox...