Go beyond the basics of Rust and build web and serverless cloud applications. The applications explained in this practical book include web sites, RESTful APIs, a real-time web chat application, and frontend application with WebAssembly. Each chapter is organized in the following format: what this kind of application looks like; requirements for the example program; an introduction to the Rust libraries used; step-by-step implementation of the example program, including common pitfalls and best practices; and a brief comparison of libraries and frameworks in the same domain. This book will open your eyes to the world of practical web applications of Rust. After reading the book, you will be able to apply your Rust knowledge to build your own web projects. What You Will Learn Build dynamic websites with databases Build RESTful APIs Write a WebSocket server that can power a real-time chat app in Rust Discover the benefits of serverless computing using Amazon Web Service's Rust support Compile Rust to WebAssembly for high-performance frontend applications Who This Book Is For A reader with basic Rust knowledge, wishing to learn more about how to apply Rust in a real-world scenario. A developer who is evaluating the possibility to build their next project in Rust.
Author(s): Shing Lyu
Publisher: Apress
Year: 2021
Language: English
Pages: 256
Table of Contents
About the Author
About the Technical Reviewer
Chapter 1: Rust in the Web World
Who Is This Book For?
Who Is This Book Not For?
Criteria for Selecting Libraries
Pure-Rust
Maturity
Popularity
How To Use This Book
Chapter Overview
Source Code
Chapter 2: Developing Websites
What Are You Building?
Hello World!
Serving Static Files
Rendering Dynamic Templates
Using a Database
Adding Cats with a Form
Showing the Cat Detail Page
Other Alternatives
Chapter 3: REST APIs
What Are You Building?
Converting the Cats List to a REST API
API Testing
Building the Cat Detail API
Input Validation
Error Handling
Using a ResponseBuilder or Response
Using the actix web::error Helpers
Using a Generic Error That Implemented the ResponseError Trait
Using a Custom-Built Error Type
Customize the web::Path Extractor Error
Logging
Enabling HTTPS
Other Alternatives
Chapter 4: Chatting in Real-Time with WebSocket
Introduction to WebSocket
What Are You Building?
A WebSocket Echo Server
Pushing Notifications from the Server
Cleaning Up Unresponsive Clients
Two-Way Chat
Sending Structural JSON Data
Other Alternatives
Chapter 5: Going Serverless
What Are You Building?
Registering an AWS Account
Hello World in Lambda
Making a REST API with Lambda
Using the Serverless Framework
Building the /cats API
Building the Upload API
Uploading the Image Using S3 Presigned URL
Adding the Frontend
Other Alternatives
Chapter 6: High-Performance Web Frontend Using WebAssembly
What Is WebAssembly?
What Are You Building?
Hello WebAssembly!
Setting Up the Development Environment
Creating the Project
Creating the Frontend
Resizing Images with WebAssembly
Loading an Image File Onto the