Leanpub Header

Skip to main content

Rust for Systems Programming: From Memory Fundamentals to High-Performance Software

A comprehensive guide to building reliable, secure and efficient systems software with Rust

Rust for Systems Programming: From Memory Fundamentals to High-Performance Software
This book is 100% completeLast updated on 2026-10-19

Ready to move beyond the basics of Rust? This book takes you inside the language, from ownership and memory management to concurrency, networking and performance optimization. Build real systems projects, learn to track down tricky bugs and gain the skills to write Rust software that is fast, secure and reliable.

Minimum price

$35.00

$49.00

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

PDF
EPUB
WEB
APP
485
Pages
About

About

About the Book

This book teaches you how to write production-grade systems software in Rust. You will learn not only the syntax and idioms of the language, but also how Rust works internally: its ownership model, memory layout, compilation pipeline, concurrency guarantees and performance characteristics. Through complete, self-contained projects, you will build a robust command-line tool, a binary file parser, a concurrent worker pool, a TCP server, an asynchronous networking service and a C interoperability library. Each concept is grounded in verified sources from the Rust documentation, The Rustonomicon, compiler internals and authoritative systems programming references. The book assumes you already know how to program in a systems language and takes you to the level where you can design, implement, debug, optimize and deploy Rust systems that are fast, correct and maintainable.

Author

About the Author

Steve Publications

Steve is a technology professional with over 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. He specializes in analyzing complex systems, identifying weaknesses and improving security.

Beyond his professional work, Steve collaborates with researchers and industry experts to create practical technical books covering software development, cybersecurity, cloud computing, DevOps, AI and enterprise technologies. His goal is to help IT professionals, students and enthusiasts develop practical skills through clear explanations, real-world examples and hands-on exercises.

At Steve Publications, we use AI to assist with translation, proofreading and editing but not to replace the research, technical expertise or hands-on experience behind our books. Some authors publish under pseudonyms for privacy or professional reasons.

Every book is written, reviewed and maintained by experienced professionals, supported by a private community of over 420 engineers and researchers. We prioritize technical accuracy, practical value and regularly updated content over mass-produced AI-generated text.

We welcome experienced professionals interested in writing or reviewing books, especially in specialized and emerging technology fields. If you'd like to contribute, contact us with your area of expertise.

We stand behind our work. If a book doesn't meet your expectations, Leanpub offers a 60-day money-back guarantee.

Contents

Table of Contents

A comprehensive guide to building reliable, secure and efficient systems software with Rust

Introduction

  1. Book Organization
  2. Toolchain and Edition
  3. How to Read This Book

Chapter 1: Why Rust for Systems Programming

  1. What Systems Programming Demands
  2. The Rust Value Proposition
  3. Historical Context: From C to Rust
  4. When Rust Is the Right Choice
  5. When Rust Is Not
  6. The Book’s Approach and Projects

Chapter 2: The Rust Toolchain and Build System

  1. Installing and Configuring the Toolchain
  2. Understanding rustc and the Compilation Pipeline
  3. Cargo Projects and Directory Layout
  4. Dependency Management and Version Resolution
  5. Features, Profiles and Build Scripts
  6. Cross-Compilation and Target Management
  7. Summary

Chapter 3: Modules, Crates and Visibility

  1. Crates vs Modules vs Packages
  2. The Module System and File Structure
  3. Visibility Rules and pub Paths
  4. Use Statements and Paths
  5. Procedural Macros and Derive
  6. Conditional Compilation with cfg
  7. Summary

Chapter 4: Types, Expressions and Control Flow

  1. Primitive Types and Their Sizes
  2. Type Inference and Annotations
  3. Compound Types: Tuples and Arrays
  4. Functions, Parameters and Return Values
  5. Control Flow: Match, If, Loops
  6. Closures and Capture Semantics
  7. Summary

Chapter 5: Ownership, Borrowing and Lifetimes

  1. The Ownership Rules
  2. Move Semantics and Transfer of Ownership
  3. Borrowing and References
  4. Reborrowing and Mutable Borrowing
  5. Lifetimes and Lifetime Elision
  6. Non-Lexical Lifetimes (NLL)
  7. Summary

Chapter 6: The String and Slice Types

  1. str vs String vs String Literal
  2. UTF-8 Encoding and Character Boundaries
  3. Slices and Borrowed Views
  4. Performance of String Operations
  5. Working with Bytes and Encodings
  6. Custom String-Like Types
  7. Summary

Chapter 7: Collections and Data Structures

  1. Vec: The Dynamic Array
  2. VecDeque and LinkedList
  3. HashMap and HashSet
  4. BinaryHeap and BTreeMap
  5. Custom Collection Implementations
  6. Choosing the Right Collection
  7. Summary

Chapter 8: Generics, Traits and Trait Objects

  1. Generic Functions and Types
  2. Trait Definition and Implementation
  3. Trait Bounds and Where Clauses
  4. Associated Types and Type Aliases
  5. Trait Objects and Dynamic Dispatch
  6. Const Generics and Advanced Patterns
  7. Summary

Chapter 9: Smart Pointers and Interior Mutability

  1. Box and Heap Allocation
  2. Rc and Arc for Shared Ownership
  3. Interior Mutability: Cell and RefCell
  4. Mutex Guards and RwLock
  5. Pin and Self-Referential Types
  6. Designing Custom Smart Pointers
  7. Summary

Chapter 10: Stack, Heap and Data Layout

  1. Stack Allocation and Call Frames
  2. Heap Allocation and the Global Allocator
  3. Data Layout, Alignment and Padding
  4. Repr Attributes and ABI Control
  5. Sized vs Dynamically Sized Types
  6. Measuring and Optimizing Layout
  7. Summary

Chapter 11: Raw Pointers and Unsafe Rust

  1. When Unsafe Is Necessary
  2. Raw Pointer Operations
  3. Unsafe Functions and Blocks
  4. Soundness and Undefined Behavior
  5. Pointer Provenance and Validity
  6. Establishing and Maintaining Invariants
  7. Summary

Chapter 12: Initialization, MaybeUninit and Volatile

  1. Uninitialized Memory and ZSTs
  2. MaybeUninit: Safe Uninitialized Buffers
  3. Partial Initialization and Cleanup
  4. Volatile Operations
  5. Atomic Operations and Memory Ordering
  6. FFI-Safe Initialization
  7. Summary

Chapter 13: The Drop Trait and RAII

  1. The Drop Trait and Destruction Order
  2. RAII Pattern in Rust
  3. Drop Guards and Scoped Resources
  4. Interaction with Move and Clone
  5. Leak and Forget Semantics
  6. Designing Resource-Safe APIs
  7. Summary

Chapter 14: System Calls and OS Interfaces

  1. The Role of libc and syscalls
  2. Platform Abstraction Strategies
  3. Processes and Subprocess Management
  4. Environment Variables and Command-Line Arguments
  5. Signals and Interrupt Handling
  6. Cross-Platform System Programming
  7. Summary

Chapter 15: Filesystem and File I/O

  1. Path Types and Cross-Platform Paths
  2. File Handles and Descriptors
  3. Buffered and Raw I/O
  4. Directory Operations and Traversal
  5. Memory-Mapped Files
  6. Permissions, Ownership and Metadata
  7. Summary

Chapter 16: Networking and Sockets

  1. Socket Types and Address Families
  2. TCP Client and Server Programming
  3. UDP and Connectionless Communication
  4. Nonblocking I/O and Polling
  5. Protocol Implementation Strategies
  6. Network Error Handling
  7. Summary

Chapter 17: Threads and Shared-State Concurrency

  1. Thread Creation and Lifetime Management
  2. Scoped Threads
  3. Send and Sync Traits
  4. Mutex and Shared Mutable State
  5. RwLock for Read-Mostly Data
  6. Condition Variables and Synchronization
  7. Summary

Chapter 18: Message Passing and Channels

  1. Channel Semantics and Variants
  2. mpsc: Multiple Producer, Single Consumer
  3. Watch and Oneshot Channels
  4. Actor Pattern Implementation
  5. Work Distribution with Channels
  6. When to Choose Messages Over State
  7. Summary

Chapter 19: Atomics and Lock-Free Programming

  1. Atomic Types and Operations
  2. Memory Ordering Explained
  3. Building Lock-Free Data Structures
  4. Double-Checked Locking
  5. ABA Problem and Solutions
  6. When Lock-Free Is Worth It
  7. Summary

Chapter 20: Asynchronous Programming with Futures

  1. Why Async: The C10K Problem
  2. Futures and Poll Semantics
  3. Async and Await Syntax
  4. Executors and Task Scheduling
  5. Async I/O and Epoll/Kqueue/IOCP
  6. Task Cancellation, Join and Select
  7. Summary

Chapter 21: Concurrent Architecture Patterns

  1. Thread Pools and Work Scheduling
  2. Event Loops and Reactor Pattern
  3. Hybrid Sync/Async Architectures
  4. Backpressure and Flow Control
  5. Deadlock, Livelock and Starvation
  6. Choosing Between Concurrency Models
  7. Summary

Chapter 22: Foreign Function Interface

  1. FFI Basics and extern Blocks
  2. Calling Conventions and ABI Compatibility
  3. Representing C Types in Rust
  4. Ownership Across Language Boundaries
  5. Callbacks and Function Pointers
  6. Panics Across the Boundary
  7. Building Safe FFI Wrappers
  8. Summary

Chapter 23: Binary Formats and Serialization

  1. Endianness and Byte Order
  2. Manual Binary Parsing
  3. Serde and Serialization Frameworks
  4. Compact Binary Formats
  5. Parsing Untrusted Binary Input
  6. Memory-Efficient Deserialization
  7. Summary

Chapter 24: No Std and Embedded Rust

  1. The Difference Between std and core
  2. Setting Up no_std Projects
  3. Custom Allocators
  4. Panic Strategies in no_std
  5. Hardware Registers and Memory-Mapped I/O
  6. Cross-Compilation for Embedded Targets
  7. Summary

Chapter 25: Dynamic and Static Linking

  1. Library Types: lib, dylib, cdylib, staticlib
  2. Linking Models and Trade-Offs
  3. Executable Formats: ELF, Mach-O, PE
  4. Symbol Visibility and Link-Time Optimization
  5. Building Shared Libraries
  6. Deployment and Distribution
  7. Summary

Chapter 26: Security Engineering in Rust

  1. Rust’s Safety Guarantees (and Their Limits)
  2. Integer Overflow and Wrapping Arithmetic
  3. Buffer Safety and Bounds Checking
  4. Path Traversal and Filesystem Security
  5. Dependency Supply Chain and Auditing
  6. Cryptographic API Usage and Best Practices
  7. Summary

Chapter 27: Performance Engineering

  1. Understanding Rust’s Optimization Pipeline
  2. Cache Locality and Data-Oriented Design
  3. Memory Allocation Overhead
  4. Branch Prediction and Control Flow
  5. Vectorization and SIMD
  6. Release Builds, LTO and PGO
  7. Summary

Chapter 28: Profiling and Benchmarking

  1. Benchmarking with Criterion
  2. CPU Profiling and Flame Graphs
  3. Memory Profiling
  4. Hardware Performance Counters
  5. Assembly-Level Analysis
  6. Microbenchmarking Pitfalls
  7. Summary

Chapter 29: Testing, Debugging and Reliability

  1. Unit, Integration and Doc Tests
  2. Property-Based Testing with Proptest
  3. Fuzzing with AFL and Honggfuzz
  4. Miri for Undefined Behavior Detection
  5. Sanitizers: ASan, TSan, MSan
  6. Debugging and Core Dumps
  7. Summary

Chapter 30: Logging, Tracing and Observability

  1. Logging with the log Crate
  2. Structured Logging
  3. Tracing with the tracing Crate
  4. Span-Based Instrumentation
  5. Metrics and Telemetry
  6. Observability in Production
  7. Summary

Chapter 31: Building a High-Performance Network Service

  1. Requirements and Architecture Design
  2. Async Server Implementation
  3. Connection Handling and Protocol
  4. Concurrency and Backpressure
  5. Performance Optimization
  6. Testing and Deployment
  7. Summary

Chapter 32: Real-World Rust Systems and Case Studies

  1. Rust in the Linux Kernel
  2. Firecracker: Lightweight VM Management
  3. Cloudflare’s Rust Migration
  4. Discord’s Performance Improvements
  5. The Rust Ecosystem for Systems Programming
  6. Common Mistakes and Anti-Patterns
  7. Supply Chain and Security
  8. Career and Community
  9. Summary

Conclusion

Glossary

  1. A
  2. B
  3. C
  4. D
  5. E
  6. G
  7. H
  8. I
  9. J
  10. K
  11. L
  12. M
  13. N
  14. O
  15. P
  16. Q
  17. R
  18. S
  19. T
  20. U
  21. V
  22. W
  23. X
  24. Y
  25. Z

Rust Systems Programming Reference

  1. Essential Types and Sizes
  2. Key Traits
  3. Memory Ordering
  4. Common Unsafe Patterns
  5. Essential Macros
  6. Essential Standard Library Modules

Tools and Workflows Reference

  1. Essential Tools
  2. Essential Workflows
  3. Development Environment
  4. CI Pipeline Example

References

Further Reading

  1. Core Rust Resources
  2. Systems and Concurrency
  3. Performance and Optimization
  4. Embedded and Bare Metal
  5. Security
  6. Operating Systems and Kernel Development
  7. Community and Development

Roadmap for Production Systems

  1. Phase 1: Foundation (Weeks 1-4)
  2. Phase 2: Systems Basics (Weeks 5-8)
  3. Phase 3: Concurrency (Weeks 9-12)
  4. Phase 4: Advanced Topics (Weeks 13-16)
  5. Phase 5: Production Readiness (Weeks 17-20)
  6. Phase 6: Specialization (Weeks 21+)
  7. Ongoing Practices
  8. Production Checklist

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub