Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Prabhu Eshwarla

Deliver fast, reliable, and maintainable applications by building backend servers, services, and frontends all in nothing but Rust. In Rust Servers, Services, and Apps, you’ll learn: • Developing database-backed web services in Rust • Building and securing RESTful APIs • Writing server-side web applications in Rust • Measuring and benchmarking web service performance • Packaging and deploying web services • Full-stack Rust applications The blazingly fast, safe, and efficient Rust language has been voted “most loved” for multiple consecutive years on the StackOverflow survey. Rust Server, Services, and Apps shows you why! Inside, you’ll build web servers, RESTful services, server-rendered apps, and client frontends just using Rust. You’ll learn to write code with small and predictable resource footprints, and build high-performing applications with unmatched safety and reliability. About the technology Build speedy, stable, and safe web servers in Rust! With a unique approach to memory management and concurrency, Rust excels at getting the low-level details right so your applications run fast and flawlessly. And Rust’s incredible compiler helps you avoid expensive mistakes when you’re deploying web services and other core components in production. About the book Rust Servers, Services, and Apps shows you how to create modern distributed web apps using the Rust language. You’ll start with the basics: building a simple HTTP server and a RESTful web service. Then, you’ll make them production ready by adding security, database interactivity, and error handling. Finally, you’ll tackle a digital storefront service, create a single page app, and dig into asynchronous programming. All examples are fully illustrated and include annotated code you can easily adapt to your own projects. About the reader For web developers who know the basics of Rust.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on, project-driven guide for web developers with basic Rust knowledge who want to build production-ready backend servers, RESTful APIs, server-rendered apps, and even full-stack frontends—all in Rust, from raw TCP sockets to async frameworks like Actix Web. 【Book Arc】 - **Opening (~0%–9%)**: Introduces why Rust is a strong choice for web applications, covering memory safety, thread safety, and the elimination of common bugs like null dereferences and buffer overflows. It also sets up the book's running example: EzyTutors, a digital storefront for tutors. - **Early (~9%–25%)**: Explains networking fundamentals—TCP/IP model, OSI layers—and then dives into building a basic TCP server and client from scratch using only Rust's standard library, introducing the `Read` and `Write` traits. - **Early (~25%–34%)**: Extends the TCP work into a minimal HTTP server, implementing request parsing (GET/POST), response construction, and serialization into proper HTTP messages, complete with unit tests for 200 and 404 responses. - **Middle (~34%–44%)**: Adds a handler trait to serve static pages and 404s, then transitions to the Actix Web framework, highlighting its features (HTTP/2, middleware, async I/O) and building a health-check API with application state and route configuration. - **Middle (~44%–end of excerpts)**: Begins building RESTful web services with Actix, covering CRUD operations, database persistence, error handling, state management, JWT authentication, and middleware—all within the EzyTutors context. 【Key Takeaways】 - **Rust's ownership model is the core advantage for web servers** (Early): It eliminates null pointer dereferences, segfaults, dangling pointers, and buffer overflows at compile time, without needing a garbage collector. This means safer, more predictable backend code. - **Start from raw TCP, not frameworks** (Early): The book builds a TCP server and client using only `std::net::TcpStream` and the `Read`/`Write` traits, showing how bytes flow over the wire before abstracting with HTTP. - **HTTP is just structured bytes** (Early): You'll parse GET/POST requests into Rust structs and serialize responses with status lines, headers, and bodies—demystifying what frameworks do under the hood. - **Test your protocol code early** (Early): The book includes unit tests for constructing 200 and 404 responses, ensuring your HTTP structs serialize correctly before building higher-level features. - **Actix Web is a mature, high-performance choice** (Middle): It supports HTTP/1.x and HTTP/2, async I/O, middleware (CORS, sessions, auth), content compression, and multiple database connections—making it ideal for production REST APIs. - **Application state is shared via extractors** (Middle): Using `web::Data<T>` with a struct like `AppState` (containing a visit counter with `Mutex`) shows how to manage shared, mutable state safely across handlers. - **The book is deliberately scoped** (Early): It focuses only on REST (not SOAP) and skips CI/CD, but includes Docker/Docker Compose deployment and a brief look at peer-to-peer networks for async practice. 【Reading Tips】 - **Skim the opening chapters** (~0–9%) if you already know Rust's safety guarantees; the real value starts with the TCP server code. - **Deep-read the HTTP server section** (~25–34%): This is where you'll truly understand request/response parsing and serialization—don't rush through the listings and tests. - **Follow along with the EzyTutors example** throughout; it ties every chapter together, from static pages to REST APIs, so keep the project vision in mind. - **Hard spot**: The transition from raw TCP to Actix Web can feel jarring—expect to see framework abstractions (like `web::Data` and route config) that assume you've internalized the earlier manual HTTP work. - **Take away the testing mindset**: The book's habit of writing unit tests for HTTP structs is a pattern you should replicate in your own projects. 【Coverage Limits】 This guide covers the book's opening through the early REST API chapters (~44% of the book). Excerpts do not cover later topics like full database integration, JWT auth implementation, frontend development, async programming deep dives, or Docker deployment—those appear in later chapters not included here.
Excerpt 1
who know the basics of Rust. Prabhu Eshwarla M A N N I N G brief contents PART 1 WEB SERVERS AND SERVICES ............................................ 1 1 ■...
View in text
Excerpt 2
ous integration/continuous delivery (CI/CD). These are very important topics in today’s practice, but there was nothing specific to Rust to be explained and...
View in text
Excerpt 3
s: #[derive(Debug, PartialEq)] pub enum Method { Get, Post, Uninitialized, } The trait implementation for Method is shown next (also to be added to http- req...
View in text
Excerpt 4
which means it communicates through messages over a network. Web services use HTTP as the primary protocol for exchang- ing messages. Several architectural s...
View in text
Excerpt 5
tion to database (iteration 1) 87 D qu ro th pas refe the d copsql -U $DATABASE_USER -d ezytutors --password select * from ezy_course_c4; You should see resu...
View in text
Excerpt 6
end state of chapter 3 as the starting point for chapter 4. Let’s now take a quick tour of the basics of error handling in Rust, which we can then put to use...
View in text
Excerpt 7
script async fn post_course_success() in handlers.rs to add unwrap() on the return value from the database access function: #[actix_rt::test] async fn post_c...
View in text
Excerpt 8
s yet another test course".into()), UpdateCourse struct to course_format: None, provide the data elements course_level: Some("Intermediate".into()), to modif...
View in text
Tags
AI categories
Programming LanguageBackendWeb Technology
ISBN: 1617298603
Publish Year: 2023
Language: English
Pages: 330
File Format: PDF
File Size: 9.5 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…