
Rust Web Development with Rocket: A practical guide to starting your journey in Rust web development using the Rocket framework
- Length: 420 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-06-30
- ISBN-10: 180056130X
- ISBN-13: 9781800561304
- Sales Rank: #8545217 (See Top 100 Books)
xplore the world of Rocket-fueled web application development and the power of the Rust programming language
Key Features
- Discover solutions to the common problems faced while creating web applications with Rocket
- Learn everything about Rust, from structs and crates to generics and debugging
- Combine Rust and Rocket to create, test, and deploy a full-featured web app
Book Description
Looking for a fast, powerful, and intuitive framework to build web applications? This Rust book will help you kickstart your web development journey and take your Rust programming skills to the next level as you uncover the power of Rocket – a fast, flexible, and fun framework powered by Rust.
Rust Web Development with Rocket wastes no time in getting you up to speed with what Rust is and how to use it. You’ll discover what makes it so productive and reliable, eventually mastering all of the concepts you need to play with the Rocket framework while developing a wide set of web development skills. Throughout this book, you’ll be able to walk through a hands-on project, covering everything that goes into making advanced web applications, and get to grips with the ins and outs of Rocket development, including error handling, Rust vectors, and wrappers. You’ll also learn how to use synchronous and asynchronous programming to improve application performance and make processing user content easy.
By the end of the book, you’ll have answers to all your questions about creating a web application using the Rust language and the Rocket web framework.
What you will learn
- Master the basics of Rust, such as its syntax, packages, and tools
- Get to grips with Rocket’s tooling and ecosystem
- Extend your Rocket applications using Rust and third-party libraries
- Create a full-fledged web app with Rocket that handles user content
- Write pattern-matching logic and handle Rust object lifetimes
- Use APIs and async programming to make your apps secure and reliable
- Test your Rocket application and deploy it to production
- Containerize and scale your applications for maximum efficiency
Who this book is for
This web development book is for software engineers who want to learn how to use the Rocket framework to build web applications. Although not mandatory, basic knowledge of the Rust programming language will help you understand the topics covered easily.
Rust Web Development with Rocket Contributors About the author About the reviewer Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Part 1: An Introduction to the Rust Programming Language and the Rocket Web Framework Chapter 1: Introducing the Rust Language Technical requirements An overview of the Rust language Why use the Rust language? Installing the Rust compiler toolchain Installing rustup on the Linux OS or macOS Installing a different toolchain and components Updating the toolchain, rustup, and components Writing Hello World! Writing a more complex program Packages and Cargo Cargo package layout Using third-party crates Tools and getting help Tools Text editor Getting help and documentation Summary Chapter 2: Building Our First Rocket Web Application Technical requirements Introducing Rocket – a web framework written in the Rust language The HTTP request life cycle in Rocket Rocket launch sequence Creating our first Rocket web application An asynchronous application Configuring our Rocket web application Starting the Rocket application in different profiles Configuring the Rocket web application Configuring the Rocket application using Rocket.toml Overriding the configuration with environment variables Getting help Summary Chapter 3: Rocket Requests and Responses Technical requirements Understanding Rocket routes HTTP methods URI Path Query Rank Format Data Implementing route handlers Creating responses Wrapping Responder Built-in implementations Making default error catchers Summary Chapter 4: Building, Igniting, and Launching Rocket Technical requirements Managing state Working with a database Attaching Rocket fairings Rocket phases Fairing callbacks Implementing and attaching fairings Connecting to a database using rocket_db_pools Summary Chapter 5: Designing a User-Generated Application Technical requirements Designing a user-generated web application Planning the user struct Creating user routes Making user-generated contents Finalizing the application Modularizing the Rocket application Summary Part 2: An In-Depth Look at Rocket Web Application Development Chapter 6: Implementing User CRUD Technical requirements Implementing GET user Implementing GET users Implementing POST user Implementing PUT and PATCH user Implementing DELETE user Summary Chapter 7: Handling Errors in Rust and Rocket Technical requirements Using panic! Catching panic! Using shutdown Using Option Returning Result Creating a custom error type Logging errors Summary Chapter 8: Serving Static Assets and Templates Technical requirements Serving static assets Introducing the Tera template Showcasing users Working with forms Securing HTML forms from CSRF Summary Chapter 9: Displaying Users' Post Technical requirements Displaying posts – text, photo, and video Using generic data types and trait bounds Learning about ownership and moving Borrowing and lifetime Implementing borrowing and lifetime Summary Chapter 10: Uploading and Processing Posts Technical requirements Uploading a text post Uploading a photo post Processing files asynchronously Uploading a video post and process using a worker Summary Chapter 11: Securing and Adding an API and JSON Technical requirements Authenticating users Authorizing users Handling JSON Protecting the API with a JWT Summary Part 3: Finishing the Rust Web Application Development Chapter 12: Testing Your Application Technical requirements Testing the Rust program Testing the Rocket application Debugging the Rust application Summary Chapter 13: Launching a Rocket Application Technical requirements Optimizing production binaries Setting up the Apache HTTP Server with a Rocket application Generating Docker images for a Rocket application Summary Chapter 14: Building a Full Stack Application Technical requirements Introducing WebAssembly Setting up a Cargo workspace Setting a WebAssembly build target Writing a WebAssembly application using Yew Serving a WebAssembly application using Rocket Summary Chapter 15: Improving the Rocket Application Technical requirements Extending the Rocket application Adding logging Expanding logging to tracing Setting monitoring Setting up a mailing and alerting system Scaling the Rocket application Exploring alternative Rust web frameworks Actix Web Tide Warp Summary Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Rust Web Development with Rocket: A practical guide to starting your journey in Rust web development using the Rocket framework
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.