Book Image

Practical System Programming for Rust Developers

By : Prabhu Eshwarla
Book Image

Practical System Programming for Rust Developers

By: Prabhu Eshwarla

Overview of this book

Modern programming languages such as Python, JavaScript, and Java have become increasingly accepted for application-level programming, but for systems programming, C and C++ are predominantly used due to the need for low-level control of system resources. Rust promises the best of both worlds: the type safety of Java, and the speed and expressiveness of C++, while also including memory safety without a garbage collector. This book is a comprehensive introduction if you’re new to Rust and systems programming and are looking to build reliable and efficient systems software without C or C++. The book takes a unique approach by starting each topic with Linux kernel concepts and APIs relevant to that topic. You’ll also explore how system resources can be controlled from Rust. As you progress, you’ll delve into advanced topics. You’ll cover network programming, focusing on aspects such as working with low-level network primitives and protocols in Rust, before going on to learn how to use and compile Rust with WebAssembly. Later chapters will take you through practical code examples and projects to help you build on your knowledge. By the end of this Rust programming book, you will be equipped with practical skills to write systems software tools, libraries, and utilities in Rust.
Table of Contents (17 chapters)
1
Section 1: Getting Started with System Programming in Rust
6
Section 2: Managing and Controlling System Resources in Rust
12
Section 3: Advanced Topics

What this book covers

Chapter 1, Tools of the Trade – Rust Toolchains and Project Structures, introduces the Rust toolchain for build and dependency management, automated testing, and documentation.

Chapter 2, A Tour of the Rust Programming Language, illustrates the key concepts of the Rust programming language including the type system, data structures, and memory management fundamentals through an example project.

Chapter 3, Introduction to the Rust Standard Library, introduces key modules of the Rust standard library that provide the building blocks and pre-defined functionality for system programming in Rust.

Chapter 4, Managing Environment, Command Line, and Time, covers a few foundational topics around how to programmatically deal with command-line parameters, set and manipulate the process environment, and work with system time.

Chapter 5, Memory Management in Rust, provides a comprehensive look at the memory management facilities provided by Rust. We will review Linux memory management basics, the traditional shortcomings of C/C++, and how Rust can be used to overcome many of these shortcomings.

Chapter 6, Working with Files and Directories in Rust, helps you understand how the Linux filesystem works, and how to master the Rust Standard Library for various scenarios in file and directory operations.

Chapter 7, Implementing Terminal I/O in Rust, helps you understand how a pseudo-terminal application works and how to create one. The result will be an interactive application that handles streams.

Chapter 8, Working with Processes and Signals, provides an explanation of what processes are, how to handle them in Rust, how to create and communicate with a child process, and how to handle signals and errors.

Chapter 9, Managing Concurrency, explains the basics of concurrency and various mechanisms for sharing data across threads in an idiomatic way in Rust, including channels, mutexes, and reference counters.

Chapter 10, Working with Device I/O, explains Linux I/O concepts such as buffering, standard inputs and outputs, and device I/O, and shows how to control I/O operations with Rust.

Chapter 11, Learning Network Programming, explains how to work with low-level network primitives and protocols in Rust, illustrated by building low-level TCP and UDP servers and clients, and a reverse proxy.

Chapter 12, Writing Unsafe Rust and FFI, describes the key motivations and risks associated with unsafe Rust, and shows how to use FFI to safely interface Rust with other programming languages.