Cookin' with Rust
This Rust Cookbook is a collection of simple examples that demonstrate good practices to accomplish common programming tasks, using the crates of the Rust ecosystem.
Read more about Rust Cookbook, including tips for how to read the book, how to use the examples, and notes on conventions.
Contributing
This project is intended to be easy for new Rust programmers to contribute to, and an easy way to get involved with the Rust community. It needs and welcomes help. For details see CONTRIBUTING.md.
Algorithms
Command Line
| Recipe | Crates | Categories |
|---|---|---|
| Parse command line arguments | ||
| ANSI Terminal |
Compression
| Recipe | Crates | Categories |
|---|---|---|
| Decompress a tarball | ||
| Compress a directory into a tarball | ||
| Decompress a tarball while removing a prefix from the paths |
Concurrency
Cryptography
| Recipe | Crates | Categories |
|---|---|---|
| Calculate the SHA-256 digest of a file | ||
| Sign and verify a message with an HMAC digest | ||
| Salt and hash a password with PBKDF2 |
Data Structures
| Recipe | Crates | Categories |
|---|---|---|
| Define and operate on a type represented as a bitfield |
Database
| Recipe | Crates | Categories |
|---|---|---|
| Create a SQLite database | ||
| Insert and Query data | ||
| Create tables in a Postgres database | ||
| Insert and Query data | ||
| Aggregate data |
Date and Time
Development Tools
Debugging
Versioning
Build Time
| Recipe | Crates | Categories |
|---|---|---|
| Compile and link statically to a bundled C library | ||
| Compile and link statically to a bundled C++ library | ||
| Compile a C library while setting custom defines |
Encoding
File System
Hardware Support
| Recipe | Crates | Categories |
|---|---|---|
| Check number of logical cpu cores |
Memory Management
| Recipe | Crates | Categories |
|---|---|---|
| Declare lazily evaluated constant |
Networking
| Recipe | Crates | Categories |
|---|---|---|
| Listen on unused port TCP/IP |
Operating System
Science
science/mathematics
Text Processing
Web Programming
Scraping Web Pages
| Recipe | Crates | Categories |
|---|---|---|
| Extract all links from a webpage HTML | ||
| Check webpage for broken links | ||
| Extract all unique links from a MediaWiki markup |
Uniform Resource Locations (URL)
Media Types (MIME)
| Recipe | Crates | Categories |
|---|---|---|
| Get MIME type from string | ||
| Get MIME type from filename | ||
| Parse the MIME type of a HTTP response |
Clients
Web Authentication
| Recipe | Crates | Categories |
|---|---|---|
| Basic Authentication |