Practical System Programming for Rust Developers
eBook - ePub

Practical System Programming for Rust Developers

Build fast and secure software for Linux/Unix systems with the help of practical examples

  1. 388 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Practical System Programming for Rust Developers

Build fast and secure software for Linux/Unix systems with the help of practical examples

About this book

Explore various Rust features, data structures, libraries, and toolchain to build modern systems software with the help of hands-on examples

Key Features

  • Learn techniques to design and build system tools and utilities in Rust
  • Explore the different features of the Rust standard library for interacting with operating systems
  • Gain an in-depth understanding of the Rust programming language by writing low-level software

Book Description

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.

What you will learn

  • Gain a solid understanding of how system resources are managed
  • Use Rust confidently to control and operate a Linux or Unix system
  • Understand how to write a host of practical systems software tools and utilities
  • Delve into memory management with the memory layout of Rust programs
  • Discover the capabilities and features of the Rust Standard Library
  • Explore external crates to improve productivity for future Rust programming projects

Who this book is for

This book is for developers with basic knowledge of Rust but little to no knowledge or experience of systems programming. System programmers who want to consider Rust as an alternative to C or C++ will also find this book useful.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weโ€™ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere โ€” even offline. Perfect for commutes or when youโ€™re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Practical System Programming for Rust Developers by Prabhu Eshwarla in PDF and/or ePUB format, as well as other popular books in Informatik & Programmierung. We have over one million books available in our catalogue for you to explore.

Information

Year
2020
Print ISBN
9781800560963
eBook ISBN
9781800562011
Edition
1

Section 1: Getting Started with System Programming in Rust

This section covers the foundational concepts behind system programming in Rust. It includes a tour of Rust's features, Cargo tools, the Rust Standard Library, modules for managing environment variables, command-line parameters, and working with time. Example projects include a parser to evaluate arithmetic expressions, writing a feature of an HTML template engine, and building a command-line tool for image processing.
This section comprises the following chapters:
  • Chapter 1, Tools of the Trade โ€“ Rust Toolchains and Project Structures
  • Chapter 2, A Tour of the Rust Programming Language
  • Chapter 3, Introduction to the Rust Standard Library
  • Chapter 4, Managing the Environment, Command Line, and Time

Chapter 1: Tools of the Trade โ€“ Rust Toolchains and Project Structures

Rust, as a modern systems programming language, has many inherent characteristics that make it easier to write safe, reliable, and performant code. Rust also has a compiler that enables a relatively fearless code refactoring experience as a project grows in size and complexity. But any programming language in itself is incomplete without the toolchains that support the software development life cycle. After all, where would software engineers be without their tools?
This chapter specifically discusses the Rust toolchain and its ecosystem, and techniques to structure code within Rust projects to write safe, testable, performant, documented, and maintainable code that is also optimized to run in the intended target environment.
The following are the key learning outcomes for this chapter:
  • Choosing the right configuration of Rust for your project
  • Cargo introduction and project structure
  • Cargo build management
  • Cargo dependencies
  • Writing test scripts and doing automated unit and integration testing
  • Automating the generation of technical documentation
By the end of this chapter, you will have learned how to select the right project type and toolchain; organize project code efficiently; add external and internal libraries as dependencies; build the project for development, test, and production environments; automate testing; and generate documentation for your Rust code.

Technical requirements

Rustup must be installed in the local development environment. Use this link for installation: https://github.com/rust-lang/rustup.
Refer to the following link for official installation instructions: https://www.rust-lang.org/tools/install.
After installation, check rustc, and cargo have been installed correctly with the following commands:
rustc --version
cargo --version
You must have access to any code editor of your choice.
Some of the code and commands in this chapter, especially those related to shared libraries and setting paths, require a Linux system environment. It is recommended to install a local virtual machine such as VirtualBox or equivalent with a Linux installation for working with the code in this chapter. Instructions to install VirtualBox can be found at https://www.virtualbox.org.
The Git repo for the examples in this chapter can be found at https://github.com/PacktPublishing/Practical-System-Programming-for-Rust-Developers/tree/master/Chapter01.

Choosing the right Rust configuration for your project

When you start with Rust programming, you have to first select a Rust release channel and a Rust project type.
This section discusses details of the Rust release channels and gives guidance on how to choose among them for your project.
Rust also allows you to build different types of binaries โ€“ standalone executables, static libraries, and dynamic libraries. If you know upfront what you will be building, you can create the right project type with the scaffolding code generated for you.
We will cover these in this section.

Choosing a Rust release channel

The Rust programming language is developed continually and there are three releases being developed simultaneously at any point in time, each called a release channel. Each channel has a purpose and has varying features and stability characteristics. The three release channels are stable, beta, and nightly. Unstable language features and libraries are developed in the nightly and beta channels, while stability guarantees are provided on the stable channel.
Rustup is the tool that installs the Rust compiler, the Rust Standard Library, the Cargo package manager, and other core tools for activities such as code formatting, testing, benchmarking, and documentation. All these tools are available in mult...

Table of contents

  1. Practical System Programming for Rust Developers
  2. Why subscribe?
  3. Preface
  4. Section 1: Getting Started with System Programming in Rust
  5. Chapter 1: Tools of the Trade โ€“ Rust Toolchains and Project Structures
  6. Chapter 2: A Tour of the Rust Programming Language
  7. Chapter 3: Introduction to the Rust Standard Library
  8. Chapter 4: Managing Environment, Command Line, and Time
  9. Section 2: Managing and Controlling System Resources in Rust
  10. Chapter 5: Memory Management in Rust
  11. Chapter 6: Working with Files and Directories in Rust
  12. Chapter 7: Implementing Terminal I/O in Rust
  13. Chapter 8: Working with Processes and Signals
  14. Chapter 9: Managing Concurrency
  15. Section 3: Advanced Topics
  16. Chapter 10: Working with Device I/O
  17. Chapter 11: Learning Network Programming
  18. Chapter 12: Writing Unsafe Rust and FFI
  19. Other Books You May Enjoy