Title Page....2
Copyright....3
Dedication....4
Contributors....5
Table of Contents....8
Preface....34
Free Benefits with Your Book....40
Chapter 1: Getting Started with Rust....42
Free Benefits with Your Book....43
Technical requirements....43
What is Rust?....43
What is Rust good for?....45
Key features of Rust....45
The Rust ecosystem....47
Why learn Rust?....48
Installation and Hello World....49
Installing Rust....49
Verifying the installation....51
Setting up your development environment....51
Setting up VS Code for Rust (recommended)....51
Hello World....52
Compiling and running your Hello World....53
Using Cargo and Crates.io....54
Verifying Cargo installation....55
What is Cargo?....56
Cargos main features....56
Stable versus Nightly Rust....57
Creating a new Rust project....57
Managing dependencies with Cargo.toml....57
Installing dependencies from Crates.io....58
Cargo.lock: keeping dependencies consistent....58
Building your project....59
Running your project with Cargo....59
Initializing a new Rust project with cargo init....59
Creating a library with cargo init --lib....60
Your first real Rust program: a CLI calculator....61
Step 1: Setting up your project....61
Step 2: Writing the calculator logic....61
Step 3: Running the program....64
What you learned....65
Functions....65
Functions example....65
Summary....67
Questions....67
Chapter 2: Rust Syntax and Functions....68
Variable declarations and mutability....69
Immutable variables....69
Mutable variables....70
Shadowing....70
Data types and structures....72
Scalar types....72
Integers....72
Floating-point numbers....72
Booleans....73
Characters....73
Compound types....73
Tuples....73
Arrays....75
Slices....75
Strings....76
Structs....77
Classic structs....77
Tuple structs....78
Unit structs....78
Struct initialization and update syntax....78
Methods and associated functions....79
Enums....81
Defining enums....81
Matching with enums....82
Enum methods....83
Functions in Rust....85
Function syntax....85
Parameter passing....86
Passing by value....86
Passing by reference....86
Passing by mutable reference....87
Return values....87
Ownership and functions....88
Control flow constructs....89
if and else statements....90
Loop constructs....90
The loop keyword....90
The while keyword....91
The for keyword....92
Using ranges with the for loop....92
Nesting loops....93
Pattern matching with match....93
Matching literals....93
Matching with variables....94
Destructuring enums....94
Combining patterns....95
Adding conditional logic with match guards....95
Matching ranges....97
Pattern matching with Option....97
Understanding Rusts approach to error handling....98
Fundamentals of error handling....98
The Result type....99
The Option type....100
Error destructuring....102
The panic! macro....102
Summary....103
Questions and assignments....104
Questions....104
Variable declarations and mutability....104
Data types and structures....104
Control flow constructs....104
Functions in Rust....104
Assignments....104
Assignment 2.1: Variable declarations and mutability....104
Assignment 2.2: Data types and structures....105
Chapter 3: Functions in Rust....106
Importance of understanding functions ....107
Defining and calling functions....107
Basic function syntax....107
Parameters and return values....108
Functions that dont return a value....109
Functions with no parameters and no return values....110
Function syntax and best practices....111
Function ownership and borrowing....112
Ownership in functions....113
Borrowing in functions....113
Immutable borrowing....114
Mutable borrowing....114
Returning values and ownership....115
Advanced function features....116
Closures....116
Capturing the environment....117
The move keyword....118
The closure traits: Fn, FnMut, and FnOnce....119
Closures in action: Higher-order functions and iterators....119
Anonymous functions and iterator methods....121
Summary....122
Questions and assignments....122
Questions....122
Defining functions....122
Function ownership and borrowing....123
Advanced function features....123
Assignments....123
Assignment 3.1: basic function implementation....123
Assignment 3.2: ownership and borrowing in functions....123
Assignment 3.3: using closures....123
Chapter 4: Ownership, Borrowing, and References....126
Objective....127
What is ownership?....127
Understanding ownership....128
Ways variables interact: Move, copy, and clone....129
The default behavior: Moving ownership....130
The exception: Automatic copying with the Copy trait....131
Explicit duplication: The Clone trait....133
Key rules of ownership in Rust....134
Each value has a single owner....134
Ownership can be transferred (moved)....135
The owner is responsible for cleaning up the value....135
Moving ownership....136
Why move ownership?....137
Moving in function calls....138
Advantages of moving ownership....139
Ownership and functions....139
Ownership transfer in function calls....140
Returning ownership....140
Borrowing and references....141
Immutable borrowing....142
Mutable borrowing....142
Borrowing rules....143
Borrowing in functions....144
Practical example: Managing a library....145
Common patterns and idioms in Rust: Ownership, borrowing, and references....146
Borrowing for read-only access....147
Mutable borrowing for modification....147
Example: Mutable borrowing in a function....147
Returning references with borrowing....148
Example: Returning a reference to the longest string....148
Pitfalls and how to avoid them....150
Forgetting ownership has moved....150
Multiple mutable references....151
Dangling references....152
Unnecessary clones....152
Summary....153
Questions and assignments....153
Questions....154
Assignments....154
Assignment 4.1: ownership in action....154
Assignment 4.2: playing with borrowing....154
Chapter 5: Composite Types in Rust and the Module System....156
Structs: Named-field collections....157
Defining structs....157
Creating instances of structs....158
Initializing structs....158
Field initialization shorthand....159
Accessing struct fields....160
Reading field values....160
Modifying struct fields....160
Updating struct instances....162
Struct update syntax....162
Cloning struct instances....163
Methods for structs....165
Defining methods....166
Calling methods....167
Associated functions intro....168
Unit-like structs....169
Defining unit-like structs....169
Use cases for unit-like structs....170
Tuple structs....171
Defining tuple structs....171
Creating instances of tuple structs....172
Accessing tuple struct fields....172
Practical example: Using tuple structs in a function....172
Empty tuples....173
Structs and ownership....173
Ownership of struct fields....174
Borrowing struct fields....175
Mutable borrowing....175
Debugging with structs....176
Implementing the Debug trait....176
Customizing debug output....177
Practical example: User profile....178
Defining the UserProfile struct....178
Adding methods to UserProfile....178
Using the UserProfile struct....179
Structs: Exercises and assignments....180
Structs: Summary....180
Enums: One of several possibilities....180
Defining and using enums....181
Enum variants can hold data....182
Enum methodsfunctions intro....184
Enum methods example....184
Using enums with structs....186
Defining structs with enum fields....186
Enums: exercises and assignments....188
Enums: summary....188
Tuples: simple ordered groups....188
Using tuples....190
Accessing tuple elements....191
Accessing elements by index....191
Practical example: employee record....192
Destructuring tuples....192
Destructuring tuples....193
Practical example: destructuring function return values....193
Destructuring in a loop....194
Returning tuples from functions....194
Returning multiple values....194
Destructuring function return values....195
Practical example: splitting a full name....195
Practical example: point in 3D space....196
Calculating the distance between points....196
Practical usage....197
Tuples: exercises and assignments....197
Tuples: summary....197
Using structs, enums, and tuples together....198
Practical example: modeling a user profile....198
Managing complexity with the module system....199
Packages and crates....199
The Package layout....200
Binary crates vs. library crates....200
Controlling scope and privacy with modules....200
Defining the module tree....201
The rules of privacy (the pub keyword)....201
Referring to items via paths....202
Absolute paths....202
Relative paths and the super keyword....202
Simplifying scope with the use keyword....203
Idiomatic use paths....204
Handling naming conflicts with as....204
Physical organization: separating modules into files....205
The module filesystem mapping....205
Summary....206
Questions and assignments....207
Questions....207
Assignments....207
Assignment 5.1: order system....207
Assignment 5.2: geometric shapes enhanced....208
Chapter 6: Introduction to Error Handling....210
Why error handling matters....210
Rusts approach to errors....211
Core tools: Result and Option....211
Introduction to Result and Option....212
The Result type....212
The Option type....214
Option example....214
When to use Result versus Option....215
Handling Result and Option (unwrapping and alternatives)....216
Unrecoverable errors: Understanding panic!....216
Introduction to unwrapping....217
Using unwrap and expect....217
Safe unwrapping with defaults....219
Using combinators....220
Propagating errors with ?....222
The problem of manual propagation....222
The ? operator for Result....223
Example: the ? operator for Result with Result....223
The ? operator for Option....226
When to use the ? operator....227
Custom error types....228
Defining custom error types with an enum....228
Implementing standard error traits....229
Using custom errors in functions....231
Simplifying custom errors with thiserror and anyhow....232
The thiserror crate....233
The anyhow crate....236
When to use thiserror versus anyhow....238
Logging errors....239
Importance of logging....239
The log crate and implementations....239
Basic setup with env_logger....239
Logging levels and configuration....241
Logging errors with Context....242
Practical examples and error handling best practices....243
Practical example: File data processing....243
Summary....247
Questions and assignments....247
Questions....247
Assignments....248
Assignment 6.1: File reading with detailed error handling....248
Assignment 6.2: Division function with custom errors (using thiserror)....248
Assignment 6.3: Finding elements with Option and ?....248
Chapter 7: Polymorphism and Lifetimes....250
Ad hoc polymorphism: defining behavior with traits....250
Defining a trait....250
Method signatures versus default implementations....251
Abstracting behavior....252
Implementing traits....253
Implementing custom types....253
The orphan rule (where implementation is allowed)....254
Trait objects....255
Static versus dynamic dispatch....257
Parametric polymorphism: abstracting with generics....258
The problem of duplication....258
Writing the same function for different types....258
The type parameter....259
Bounded parametric polymorphism (trait bounds)....260
Limiting generics with traits (T: Trait)....260
The where clause for complex constraints....261
Returning types that implement traits....261
Monomorphization....262
How Rust optimizes polymorphism (zero-cost)....263
Lifetimes: polymorphism for scope....263
The necessity of lifetimes....263
The dangling reference problem....264
How the borrow checker validates scopes....264
Generic lifetime annotations....265
The syntax....266
Annotating functions holding references....266
The relationship between input and output lifetimes....267
Lifetimes in data structures....267
Structs with references....267
The impl block for lifetime-bound structs....268
Advanced lifetime concepts....269
Lifetime elision rules....269
The static lifetime (static)....269
Applied polymorphism: a project....270
Building a zero-copy configuration parser....270
Defining the capability (the Parse trait)....271
Abstracting the input (using generics)....271
The safety guarantee....272
Validating references (integrating lifetimes)....272
Summary....273
Questions and assignment....274
Questions....274
Assignment....274
The universal media player....274
Chapter 8: Object-Oriented Programming in Rust....276
Understanding OOP principles....276
How Rust approaches OOP differently....277
Encapsulation: structs, methods, and privacy....278
Shared behavior with traits....281
Defining and implementing traits....281
Traits for polymorphism: impl Trait....284
Traits for polymorphism: trait bounds....285
Understanding static dispatch (monomorphization)....287
Dynamic polymorphism with trait objects....289
Introduction to trait objects....289
Creating trait objects: dyn Trait....289
Dynamic versus static dispatch recap....291
Object safety....292
Simulating inheritance patterns....294
Composition over inheritance....294
Sharing behavior via traits....295
Default implementations....295
Trait bounds as subclassing constraints: supertraits....296
Requiring multiple traits with ....298
Associated types....298
Object-oriented design patterns in Rust....300
Introduction to patterns in Rust....300
Builder pattern....301
State patterntyped states....303
Observer pattern....306
Strategy pattern....310
Summary....312
Questions and assignments....313
Questions....313
Assignments....314
Assignment 8.1: The private bank account (encapsulation)....314
Assignment 8.2: Animal sounds (basic traits)....314
Chapter 9: Thinking Functionally in Rust....316
Rust and functional programming....316
Iterators: Processing sequences lazily....317
Creating and consuming iterators with next()....317
Three ways to iterate....318
Three ways to iterate: iter(), iter_mut(), and into_iter()....318
The role of consumers....320
Common consumers: collect(), sum(), and fold()....321
Iterator adapters: Transforming sequences....322
The map adapter....322
The filter adapter....323
Other useful adapters and consumers....325
Closures: Capturing the environment....326
Defining closures....326
Capturing the environment....327
Closure traits: Fn, FnMut, and FnOnce....330
Pattern matching....332
Pattern matching in functional style....332
Destructuring structs and enums....332
if let and while let....335
Summary....336
Questions and assignments....337
Questions....337
Assignments....338
Assignment 9.1 (easy): Simple data filtering and transformation....338
Assignment 9.2 (advanced): Implementing a custom Fibonacci iterator....338
Chapter 10: Testing in Rust....340
Why bother with testing?....340
Types of tests in Rusts ecosystem....342
Unit tests: The building blocks....342
What are unit tests?....342
Writing your first unit test....343
Running your tests with cargo test....346
Common assertion macros....347
Testing Result and Option types....349
Testing for panics....351
Controlling test execution....353
Integration tests: Checking how parts fit together....355
Purpose of integration tests....355
Setting up integration tests....355
Our library code (srclib.rs)....356
Integration test file (testsanalyzer_integration.rs)....358
Helper functions in integration tests....359
Example shared helper (testscommonmod.rs)....359
Using shared helpers (testsanalyzer_integration.rs)....360
Documentation tests: Keeping examples correct....361
What are documentation tests?....361
Writing documentation tests....362
Controlling doc test behavior....364
Hiding lines from documentation output but not from the test....365
A brief look at Test-Driven Development (TDD)....365
TDD cycle....366
TDD benefits and a micro example....366
1. Red: Write a failing test....367
2. Green: Write minimal code to make tests pass....368
3. Refactor: Improve the code....369
Next cycle: red (for case-insensitivity)....370
TDD for an API handler....370
1. Red: Write the failing test....371
2. Green: Write minimal code to make the test pass....372
3. Refactor....373
Isolating tests with test doubles (mocks and stubs)....373
The need for isolation....373
What are test doubles? Stubs and mocks....374
Manual stubbing (with traits)....374
Mocking libraries....378
Best practices for writing good tests....379
Summary....379
Questions and assignment....381
Questions....381
Assignment....381
Chapter 11: Smart Pointers and Memory Management....384
What are smart pointers, anyway?....385
The role of smart pointers in Rusts memory model....385
Enhancing safety beyond basic ownership....385
Performance implications....386
Enabling safe concurrency....386
Key ideas behind smart pointers....386
Ownership and borrowing still apply....386
Automatic cleanup....387
Reference counting for shared data....387
Interior mutability: bending the rules safely....388
A quick tour of Rusts smart pointer toolkit....388
Box: pointing to heap-allocated data....389
Why use Box?....389
Creating and using a Box....390
Key use case: enabling recursive data structures....391
When to choose Box: performance and ownership....395
Sharing data safely: Rc and Arc....396
The concept of shared ownership....396
Rc: reference counting for single-threaded scenarios....397
Creating Rc instances and cloning references....397
Arc: atomic reference counting for multithreading....399
Using Arc to share data across threads....400
The atomic in Arc....402
Reference counting, Drop, and potential cycles....402
How Weak can break cycles....403
Interior mutability: modifying data through shared references....403
What is interior mutability and why is it needed?....404
RefCell: enforcing borrowing rules at runtime (single-threaded)....404
Using borrow() and borrow_mut()....405
Runtime panics on borrow rule violations....407
Mutex: ensuring exclusive access in concurrent code....408
Locking and unlocking with lock()....408
Combining Arc and Mutex for shared mutable state....409
RwLock for read-mostly data....411
Working effectively with smart pointers....413
Smart pointers and method calls (the Deref trait in action)....413
Implementing methods on structs that own smart pointers....416
Combining smart pointers for complex scenarios....419
Smart pointers and ownership transfer....420
Practical application: a simple graph with shared nodes (Rc>)....421
Important note on cycles and Weak....425
Summary....425
Questions and assignments....426
Questions....426
Assignment....427
Chapter 12: Managing System Resources....430
Working with files in Rust (file IO)....431
Core concepts of file operations....432
Reading from files....433
Reading an entire file into a string....433
Reading a file line by line....435
Writing to files....437
Writing a string or bytes to a file....437
Appending content to an existing file....439
Manipulating files and directories....441
Key takeaways for file IO in Rust....445
Network programming essentials in Rust....446
Fundamentals of network communication....446
Building a basic TCP server....447
Listening for connections with TcpListener....447
Handling incoming client connections....447
Reading requests and sending responses....447
Creating a basic TCP client....451
Connecting to a server with TcpStream::connect....451
Sending data and receiving responses....451
Ensuring robust and secure network applications....454
Graceful error handling in network code....455
Handling Result from network operations....455
Timeouts and non-blocking operations....457
Implementing secure connections with TLS....458
Introduction to TLS for secure communication....458
How TLS works....459
Using crates for TLS....460
Example: Setting up a basic TLS client or server....461
Best practices for system resource management....466
Efficient memory usage with IO operations....466
Optimizing file IO performance....469
Buffering strategies recap....469
Processing large files in chunks....469
Optimizing network IO performance....471
Understanding asynchronous IO for networking....471
Managing network buffers and packet sizes....471
General security principles for resource handling....472
Validating inputs from external sources....472
Principle of least privilege....472
Minimizing resource contention in concurrent scenarios....473
Real-world scenarios and examples....473
Example 1: Building a more robust HTTP server....473
Important limitation: sequential handling....478
Example 2: Command-line tool for file operations....479
Next steps....481
Summary....481
Questions and assignments....483
Questions....483
Assignments....483
Assignment 12.1: Simple file copy utility....483
Assignment 12.2: Simple key-value TCP server....484
Chapter 13: Concurrency and Parallelism....486
What are concurrency and parallelism?....486
Why write concurrent programs?....487
The classic challenges: Race conditions and deadlocks....488
Rusts promise: Compile-time safety for concurrency....489
Creating and managing threads....489
Spawning new threads with std::thread::spawn....490
Basic thread creation....490
Moving data into threads with the move closure....492
Waiting for threads to finish: JoinHandle and join()....493
Handling thread panics gracefully....494
Thread panics and their effect....496
Sharing data safely between threads....496
The perils of unsafe shared state....496
Arc: Sharing ownership atomically across threads....497
Recap: Why Rc isnt enough....497
Using Arc::clone() for thread distribution....497
Mutex: Ensuring mutual exclusion for mutable data....500
Acquiring the lock with lock()....501
The role of MutexGuard....501
Combining Arc> for shared mutable state....501
Thinking about deadlocks....504
RwLock: Allowing multiple readers or one writer....504
When to use RwLock versus Mutex....505
Message passing: Communicating between threads....507
An alternative to shared state: Channels....508
Introduction to std::sync::mpsc channels (multiple producer, single consumer)....508
Creating a channel: channel()....508
Sending data with Sender....509
Receiving data with Receiver (recv(), try_recv())....511
Using channels for thread communication and synchronization....514
A glimpse into asynchronous programming with asyncawait....517
When threads arent always the best fit (IO-bound tasks versus CPU-bound tasks)....517
Brief overview of the async and await keywords....518
Async runtimes (such as tokio or async-std)....521
Best practices for concurrent Rust....523
Prefer message passing for simplicity where possible....524
Keep critical sections (locks) short and sweet....524
Be mindful of lock ordering to avoid deadlocks....527
Trust the compiler: Leverage Rusts safety guarantees....527
Consider the granularity of your parallelism....528
Summary....529
Questions and assignment....530
Questions....530
Assignment: Concurrent file word counter....531
Chapter 14: Rust for Web Development: Building Full-Stack Applications....534
Core web concepts: a quick refresher....534
The HTTP protocol: requests, responses, and methods....535
Requests and responses....535
Common HTTP methods....535
Status codes....536
Data formats: JSON and RESTful API design....536
JSON for APIs....536
Brief on RESTful API design principles....536
Getting started with Axum....537
Project setup and dependencies....537
Hello, Web! – Your first Axum server (Getting started with Axum)....538
Understanding handlers and the router....540
Defining handler functions....540
Registering routes with Router::route....540
Building a RESTful API: an in-memory todo list....542
Project setup for the API....542
Managing shared state....544
Handling requests and extracting data....548
Implementing the CRUD API endpoints....551
All the code for the RESTful API example....556
Testing our RESTful application....564
Step 1: Run your Axum server....564
Step 2: Open a new terminal....564
Step 3: Test your API endpoints with curl....564
Adding persistence with PostgreSQL....567
Database setup....568
Integrating sqlx into the Axum project....569
Adding sqlx and dotenvy dependencies....569
Configuring DATABASE_URL....570
Installing and using sqlx-cli for migrations....570
Schema management with sqlx migrations....571
Creating and running migrations....571
Mapping Rust structs and using a connection pool....573
Using sqlx::PgPool for the connection pool....573
Deriving FromRow for our Todo struct....574
Sharing the pool in Axums AppState....576
Refactoring handlers for async database persistence....578
Writing raw SQL queries....578
Refactoring the CRUD endpoints to be fully async....579
Testing the application....582
Verifying with psql....584
A final backend step: enabling CORS....585
Frontend: WebAssembly....588
Building and using a simple Wasm module....588
Exposing Rust functions with [wasm_bindgen]....589
Building the .wasm and JavaScript glue....592
Using the Wasm module from a simple web page....594
Testing the frontend....596
Summary....599
Questions and assignment....600
Questions....600
Assignment....600
Expanding the API and using basic extractors....600
Chapter 15: System Programming in Rust: Concrete Examples....602
What defines system programming?....602
Why Rust is a strong candidate for systems work....603
The core tension: control versus abstraction....604
The systems programmers dilemma....604
Rusts solution: control without compromise....604
The bridge to unsafe: when ZCAs arent enough....606
Chapter roadmap: from low-level mechanics to practical builds....606
Low-level programming foundations in Rust....607
Rusts memory safety model: a systems perspective....607
Ownership and borrowing recap for control and safety....607
Stack versus heap: managing memory explicitly....608
The role of smart pointers in memory management....609
Venturing into unsafe Rust....609
When and why unsafe is necessary....609
The five superpowers of unsafe Rust....610
Working with raw pointers (const T and mut T)....611
Best practices for encapsulating unsafe code....614
Building practical command-line utilities....618
Designing a useful CLI tool....618
Parsing command-line arguments....620
Using std::env::args() for basic arguments....620
Introduction to argument parsing....622
Interacting with the file system....625
Reading and writing files in a CLI context....625
Directory traversal and manipulation....628
Handling standard input, output, and error streams....632
Interfacing with C code: the Foreign Function Interface (FFI)....635
The why of FFI: leveraging existing C libraries....635
Declaring and linking external C functions....636
Using extern C blocks....636
The [link] attribute and build scripts....639
Passing data between Rust and C....644
Primitive types and their equivalents....644
Working with C strings....646
Representing C structs in Rust....651
Handling pointers and callbacks....653
Creating safe Rust wrappers around unsafe C APIs....656
Practical example: using a simple custom C library from Rust....662
Prerequisite: installing a C compiler....662
A glimpse into kernel module development with Rust....669
The unique environment of kernel space....669
Essential setup for Rust kernel development....670
no_std and target specifications....670
Basic module structure (initexit functions, logging)....671
Building, loading, and further considerations....675
Compilation and loading process....675
Important caveats and next steps for exploration....677
Summary....678
Questions and assignments....680
Questions....680
Assignment....681
Enhanced command-line file analyzer....681
Chapter 16: Dockerization and Deployment of Rust Applications....684
What is Docker? An overview....684
Key benefits of using Docker....685
Why Dockerize Rust applications specifically?....686
Chapter objectives: What youll learn....687
Getting started with Docker....688
Setting up your Docker environment....688
Installing Docker Desktop (Windows, macOS, and Linux)....688
Verifying your Docker installation....689
Essential Docker concepts....689
Images and containers: The core building blocks....690
Docker Hub and container registries....691
Basic Docker commands for interaction....691
Running a container: docker run....691
Listing containers: docker ps....693
Managing images: docker images, docker pull, and docker rmi....694
Stopping and removing containers: docker stop and docker rm....695
Dockerizing your Rust application....696
Understanding the Dockerfile....696
Core instructions: FROM, WORKDIR, COPY, RUN, CMD, and EXPOSE....696
Creating a basic Dockerfile for a Rust application....698
Choosing a base Rust image....699
Copying your project and building....699
Setting the CMD to run your compiled binary....700
Final Dockerfile....700
Building Your Docker Image....702
Running your Rust application inside a Docker container....704
Optimizing Docker images for Rust....706
The importance of small and efficient images....706
Using multi-stage builds....707
Separating the build environment from the runtime environment....707
Copying artifacts....707
Choosing minimal base images for runtime....710
Considerations for Alpine and musl versus glibc....711
Leveraging Docker build cache and cargos build caching....712
Structuring COPY and RUN commands effectively....712
Stripping debug symbols and binary compression....714
Using strip....714
Using tools such as UPX....715
Managing multi-container apps with Docker Compose....716
Introduction to Docker Compose: Why you need it....717
Writing a compose.yml file....718
Defining services....718
Linking services and managing networks....720
Using environment variables for configuration....721
Managing persistent data with volumes....722
Example: A Rust application with a PostgreSQL database....724
Running and managing your application stack....728
Deploying Dockerized Rust applications....730
Overview of deployment strategies....730
Using container registries....732
Tagging your Docker images for versioning....732
Pushing images to a registry....733
Pulling images in a deployment environment....734
Summary....735
Congratulations!....736
Questions and assignments....737
Questions....737
Assignments....737
Assignment 16.1: Dockerize an existing Rust CLI or web application....737
Assignment 16.2: Create a multi-container application with Docker Compose....739
Chapter 17: Unlock Your Exclusive Benefits....742
Other Books You May Enjoy....748
Index....752
Dive deep into the essentials of Rust with this definitive guide that covers core programming features, techniques, and principles, setting a solid foundation for advanced system and web programming.
The Rust Programming Handbook is a deeply engaging and meticulously crafted book designed to immerse programmers into the intricate world of Rust’s core principles and sophisticated features. This book not only enhances your coding skills but also prepares you to tackle complex challenges in software development, optimizing your code for better performance and reliability.
You will explore Rust’s powerful concurrency models, rigorous memory safety guarantees, and its versatile trait system. Discover the foundational elements that make Rust a standout language for developing safe and efficient applications. The book will show you how these core principles can seamlessly transition into real-world applications. You will learn how to apply Rust's capabilities to systems programming and web development, extending the reach of its safety and efficiency benefits across different programming domains. Whether it's creating low-level system components or high-performance web services, the book provides practical examples to integrate Rust effectively into a variety of projects.
Elevate your coding skills and become a sought-after professional in the tech industry with this essential guide. Rust from Beginner to Professional is your definitive toolkit for mastering advanced Rust programming techniques and writing high-quality code.
This book is ideal for readers with a foundational knowledge of Rust as well as experienced developers from other programming backgrounds. Whether you're starting your journey with Rust and aiming to deepen your expertise, or you're an experienced developer in languages like C++, Java, or Python transitioning to Rust, this book offers a comprehensive understanding of its core mechanics. Technical leads and software architects who aim to implement Rust in their projects will find valuable insights into enhancing performance and safety, making it a crucial addition to their professional toolkit.