Book description
Rust in Action introduces the Rust programming language by exploring numerous systems programming concepts and techniques. You'll be learning Rust by delving into how computers work under the hood. You'll find yourself playing with persistent storage, memory, networking and even tinkering with CPU instructions. The book takes you through using Rust to extend other applications and teaches you tricks to write blindingly fast code. You'll also discover parallel and concurrent programming. Filled to the brim with real-life use cases and scenarios, you'll go beyond the Rust syntax and see what Rust has to offer in real-world use cases.About the Technology
Rust is the perfect language for systems programming. It delivers the low-level power of C along with rock-solid safety features that let you code fearlessly. Ideal for applications requiring concurrency, Rust programs are compact, readable, and blazingly fast. Best of all, Rust’s famously smart compiler helps you avoid even subtle coding errors.
About the Book
Rust in Action is a hands-on guide to systems programming with Rust. Written for inquisitive programmers, it presents real-world use cases that go far beyond syntax and structure. You’ll explore Rust implementations for file manipulation, networking, and kernel-level programming and discover awesome techniques for parallelism and concurrency. Along the way, you’ll master Rust’s unique borrow checker model for memory management without a garbage collector.
What's Inside
- Elementary to advanced Rust programming
- Practical examples from systems programming
- Command-line, graphical and networked applications
About the Reader
For intermediate programmers. No previous experience with Rust required.
About the Author
Tim McNamara uses Rust to build data processing pipelines and generative art. He is an expert in natural language processing and data engineering.
Quotes
This well-written book will help you make the most of what Rust has to offer.
- Ramnivas Laddad, author of AspectJ in Action
Engaging writing style and crisp, easy-to-grasp examples help the reader get off the ground in no time.
- Sumant Tambe, Linkedin
Rust in Action is remarkably polished!
- Christopher Haupt, Swoogo
Makes it easy to explore the language and get going with it.
- Federico Hernandez, Meltwater
I highly recommend this book to those who want to learn Rust.
- Afshin Mehrabani, Etsy
Publisher resources
Table of contents
- inside front cover
- Rust in Action
- Copyright
- dedication
- contents
- front matter
-
1 Introducing Rust
- 1.1 Where is Rust used?
- 1.2 Advocating for Rust at work
- 1.3 A taste of the language
- 1.4 Downloading the book’s source code
- 1.5 What does Rust look and feel like?
- 1.6 What is Rust?
- 1.7 Rust’s big features
- 1.8 Downsides of Rust
- 1.9 TLS security case studies
- 1.10 Where does Rust fit best?
- 1.11 Rust’s hidden feature: Its community
- 1.12 Rust phrase book
- Summary
- Part 1 Rust language distinctives
-
2 Language foundations
- 2.1 Creating a running program
- 2.2 A glance at Rust’s syntax
- 2.3 Numbers
-
2.4 Flow control
- 2.4.1 For: The central pillar of iteration
- 2.4.2 Continue: Skipping the rest of the current iteration
- 2.4.3 While: Looping until a condition changes its state
- 2.4.4 Loop: The basis for Rust’s looping constructs
- 2.4.5 Break: Aborting a loop
- 2.4.6 If, if else, and else: Conditional branching
- 2.4.7 Match: Type-aware pattern matching
- 2.5 Defining functions
- 2.6 Using references
- 2.7 Project: Rendering the Mandelbrot set
- 2.8 Advanced function definitions
- 2.9 Creating grep-lite
- 2.10 Making lists of things with arrays, slices, and vectors
- 2.11 Including third-party code
- 2.12 Supporting command-line arguments
- 2.13 Reading from files
- 2.14 Reading from stdin
- Summary
-
3 Compound data types
- 3.1 Using plain functions to experiment with an API
- 3.2 Modeling files with struct
- 3.3 Adding methods to a struct with impl
- 3.4 Returning errors
- 3.5 Defining and making use of an enum
- 3.6 Defining common behavior with traits
- 3.7 Exposing your types to the world
- 3.8 Creating inline documentation for your projects
- Summary
- 4 Lifetimes, ownership, and borrowing
- Part 2 Demystifying systems programming
- 5 Data in depth
- 6 Memory
-
7 Files and storage
- 7.1 What is a file format?
- 7.2 Creating your own file formats for data storage
- 7.3 Implementing a hexdump clone
- 7.4 File operations in Rust
- 7.5 Implementing a key-value store with a log-structured, append-only storage architecture
- 7.6 Actionkv v1: The front-end code
-
7.7 Understanding the core of actionkv: The libactionkv crate
- 7.7.1 Initializing the ActionKV struct
- 7.7.2 Processing an individual record
- 7.7.3 Writing multi-byte binary data to disk in a guaranteed byte order
- 7.7.4 Validating I/O errors with checksums
- 7.7.5 Inserting a new key-value pair into an existing database
- 7.7.6 The full code listing for actionkv
- 7.7.7 Working with keys and values with HashMap and BTreeMap
- 7.7.8 Creating a HashMap and populating it with values
- 7.7.9 Retrieving values from HashMap and BTreeMap
- 7.7.10 How to decide between HashMap and BTreeMap
- 7.7.11 Adding a database index to actionkv v2.0
- Summary
-
8 Networking
- 8.1 All of networking in seven paragraphs
- 8.2 Generating an HTTP GET request with reqwest
- 8.3 Trait objects
- 8.4 TCP
- 8.5 Ergonomic error handling for libraries
- 8.6 MAC addresses
- 8.7 Implementing state machines with Rust’s enums
- 8.8 Raw TCP
- 8.9 Creating a virtual networking device
- 8.10 “Raw” HTTP
- Summary
-
9 Time and timekeeping
- 9.1 Background
- 9.2 Sources of time
- 9.3 Definitions
- 9.4 Encoding time
- 9.5 clock v0.1.0: Teaching an application how to tell the time
- 9.6 clock v0.1.1: Formatting timestamps to comply with ISO 8601 and email standards
- 9.7 clock v0.1.2: Setting the time
- 9.8 Improving error handling
- 9.9 clock v0.1.3: Resolving differences between clocks with the Network Time Protocol (NTP)
- Summary
- 10 Processes, threads, and containers
- 11 Kernel
-
12 Signals, interrupts, and exceptions
- 12.1 Glossary
- 12.2 How interrupts affect applications
- 12.3 Software interrupts
- 12.4 Hardware interrupts
- 12.5 Signal handling
- 12.6 Handling signals with custom actions
- 12.7 Sending application-defined signals
- 12.8 Ignoring signals
- 12.9 Shutting down from deeply nested call stacks
- 12.10 A note on applying these techniques to platforms without signals
- 12.11 Revising exceptions
- Summary
- index
Product information
- Title: Rust in Action
- Author(s):
- Release date: August 2021
- Publisher(s): Manning Publications
- ISBN: 9781617294556
You might also like
audiobook
Rust in Action
This well-written book will help you make the most of what Rust has to offer. Ramnivas …
book
Rust for Rustaceans
For developers who’ve mastered the basics, this book is the next step on your way to …
video
Rust in Motion
See it. Do it. Learn it! In Rust in Motion, premier Rust experts Carol Nichols and …
book
Hands-on Rust
Rust is an exciting new programming language combining the power of C with memory safety, fearless …