Book Image

Rust Standard Library Cookbook

By : Jan Hohenheim, Daniel Durante
Book Image

Rust Standard Library Cookbook

By: Jan Hohenheim, Daniel Durante

Overview of this book

Mozilla’s Rust is gaining much attention with amazing features and a powerful library. This book will take you through varied recipes to teach you how to leverage the Standard library to implement efficient solutions. The book begins with a brief look at the basic modules of the Standard library and collections. From here, the recipes will cover packages that support file/directory handling and interaction through parsing. You will learn about packages related to advanced data structures, error handling, and networking. You will also learn to work with futures and experimental nightly features. The book also covers the most relevant external crates in Rust. By the end of the book, you will be proficient at using the Rust Standard library.
Table of Contents (12 chapters)

What this book covers

Chapter 1, Learning the Basics, builds a strong foundation of fundamental principles and techniques that are useful in all kinds of situations. It will also show you how to accept user input on the command line so that you can write, all the coming chapters in an interactive way if you wanted to.

Chapter 2, Working with Collections, gives you a comprehensive overview of all the major data collections in Rust, which includes illustrations of how data is stored in your RAM so that you're ready to choose the right collection for the right task.

Chapter 3, Handling Files and the Filesystem, shows you how to connect your existing tools with the filesystem, allowing you to store, read, and search files on your computer. We will also learn how to compress data in order to send it efficiently over the internet.

Chapter 4, Serialization, introduces you to today's most common data formats and how to (de)serialize them in Rust, enabling you to connect your programs to many services by communicating across tools.

Chapter 5, Advanced Data Structures, builds a foundation for the chapters to come by providing useful information about general modules and Rust's smart pointers. You will also learn how to generate code for annotated structures at compile time by using custom #[derive()] statements.

Chapter 6, Handling Errors, teaches you about Rust's error-handling concept and how to interact seamlessly with it by creating custom errors and loggers for your use case. We will also look at how to design structures in a way that cleans up a user's resources without them noticing.

Chapter 7, Parallelism and Rayon, brings you to the world of multithreading and proves to you that Rust really gives you fearless concurrency. You will learn how to effortlessly adapt your algorithms in order to use the full power of your CPU.

Chapter 8, Working with Futures, introduces you to asynchronous concepts for your program and prepares you for all libraries that work with futures, which are Rust's version of tasks that can run in the background of your program.

Chapter 9, Networking, helps connect you to the internet by teaching you how to set up low-level servers, respond to requests in different protocols, and communicate with the World Wide Web.

Chapter 10, Using Experimental Nightly Features, ensures that you stay ahead in your knowledge of Rust. It will show you tomorrow's way of programming by giving you a tour of the most anticipated features that are still considered unstable.