Table of contents : Table of Contents About the Authors About the Technical Reviewer Introduction Chapter 1: Welcome to the World of Rust 1.1 Who Is This Book For? 1.2 Who Is This Book Not For? 1.3 Criteria for Selecting Libraries Pure Rust Maturity Popularity 1.4 How to Use This Book Chapters Overview 1.5 Source Code 1.6 Topics Not Covered Chapter 2: Building a Command-line Program 2.1 What Are You Building? 2.2 Creating a Binary Project 2.3 Reading Command-line Arguments with std::env::args 2.4 Handling Complex Arguments with Clap 2.5 Adding Binary Flags 2.6 Printing to STDERR 2.7 Printing with Color 2.8 Reading the Cat Picture from a File 2.9 Handling Errors 2.10 Piping to Other Commands Piping to STDOUT Without Color Accepting STDIN 2.11 Integration Testing 2.12 Publishing and Distributing the Program Install from Source Publish to crates.io Building Binaries for Distribution 2.13 Conclusion Chapter 3: Creating Graphical User Interfaces (GUIs) 3.1 What Are You Building? 3.2 Building a Text-based User Interface 3.3 Showing a Dialog Box 3.4 Handling Simple Keyboard Inputs 3.5 Adding a Dialog 3.6 Multi-step Dialogs 3.7 Reading User Input 3.8 Moving to Graphical User Interfaces (GUIs) 3.9 Creating a Window 3.10 Displaying an Image 3.11 Using Glade to Design the UI 3.12 Accepting Inputs and Button Clicks 3.13 Reading a gtk::Switch 3.14 Alternatives 3.15 Conclusion Chapter 4: High-Performance Web Frontend Using WebAssembly 4.1 What Is WebAssembly? 4.2 What Are You Building? 4.3 Hello WebAssembly! Setting Up the Development Environment Creating the Project Creating the Frontend 4.4 Resizing an Image with WebAssembly Loading an Image File onto the Passing the Image to Wasm 4.5 Writing the Whole Frontend in Rust 4.6 A Hello World Example 4.7 A Cat Management Application CSS Styling Deleting Files 4.8 Wasm Alternatives 4.9 Conclusion Chapter 5: REST APIs 5.1 What Are You Building? 5.2 Hello Backend World! 5.3 Serving Static Files 5.4 Converting the Cats List to a REST API 5.5 Using a Database 5.6 Adding Cats with a POST Command 5.7 API Testing 5.8 Building the Cat Detail API 5.9 Input Validation 5.10 Error Handling Using the actix_web::error Helpers Using a Generic Error That Has Implemented the ResponseError Trait Using a Custom-Built Error Type 5.11 Customizing the web::Path Extractor Error 5.12 Logging 5.13 Enabling HTTPS 5.14 Framework Alternatives 5.15 Conclusion Chapter 6: Going Serverless with the Amazon AWS Rust SDK 6.1 What Are You Building? 6.2 What Is AWS Lambda? 6.3 Registering an AWS Account 6.4 Hello World in Lambda 6.5 The Full Architecture 6.6 Using the AWS Serverless Application Model (AWS SAM) 6.7 Setting Up AWS SAM CLI Credentials 6.8 Creating the Catdex Serverless Project 6.9 Building the Upload API 6.10 Building the /cats API 6.11 Uploading the Image Using S3 Pre-signed URL 6.12 Adding the Frontend 6.13 A Note on Security 6.14 Next Steps 6.15 Conclusion Chapter 7: Building a Game 7.1 What Are We Building? 7.2 Bevy and the Entity Component System Pattern 7.3 Creating a Bevy Project 7.4 See the World Through a Camera 7.5 Adding the Cats 7.6 Loading a Spritesheet 7.7 Moving the Cats 7.8 Creating the Ball 7.9 Can’t Defy Gravity 7.10 Making the Ball Bounce 7.11 Keeping Score 7.12 Let There Be Music 7.13 Alternatives 7.14 Conclusion Chapter 8: Physical Computing in Rust 8.1 What Are You Building? 8.2 Physical Computing on Raspberry Pi Getting to Know Your Raspberry Pi Installing Raspberry Pi OS Using Raspberry Pi Imager Installing the Rust Toolchain Understanding the GPIO Pins Building an LED Circuit Controlling the GPIO Output with Rust Reading Button Clicks 8.3 Cross-Compiling to Raspberry Pi 8.4 How Does the GPIO Code Work? 8.5 Where to Go from Here? Chapter 9: Artificial Intelligence and Machine Learning 9.1 Types of Machine Learning Models 9.2 What Are You Building? 9.3 Introducing linfa and rusty-machine 9.4 Clustering Cat Breeds with K-means Introduction to the K-means Algorithm The Training Data Exporting as a CSV Moving the Configuration into a File Setting the Configuration File at Runtime Visualizing the Data Details on Adding More Entries Setting Up K-means 9.5 Detecting Cats Versus Dogs with a Neural Network Introduction to Neural Networks Preparing the Training Data and Testing Data Setting Up the Neural Network Model Reading the Training and Testing Data Normalizing the Training Data Training and Predicting Making the Prediction 9.6 Alternatives 9.7 Conclusion Chapter 10: What Else Can You Do with Rust? 10.1 The End Is Just the Beginning 10.2 Server-side Rendered Website 10.3 Web Browser and Crawler 10.4 Mobile 10.5 Operating Systems and Embedded Devices 10.6 The Cloud 10.7 Blockchains and Cryptocurrencies 10.8 Unlimited Possibilities of Rust Index