Cookin’ with Rust
This Rust Cookbook is a collection of simple recipes 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 recipes, 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
Asynchronous
Command Line
Compression
Concurrency
Configuration
Cryptography
Data Structures
Database
Date and Time
Not sure which crate to use? See Choosing between chrono, time and jiff.
Development Tools
Debugging
Versioning
Build Time
Encoding
Error Handling
File System
Hardware Support
| Recipe | Crates | Categories |
|---|---|---|
| Check available parallelism | std | Hardware support |
| Check number of logical cpu cores | num_cpus | Hardware support |
Memory Management
Multimedia
Networking
Operating System
Parsing
Science
science/mathematics
Text Processing
WebAssembly
wasmtime is an embeddable WebAssembly runtime. These recipes
cover the host embedding API — loading modules, calling exports, sharing
linear memory, and wiring up host-defined functions that guests can call back
into.
The recipes live outside the main workspace because wasmtime is a large
dependency not used elsewhere. Run them with
cargo run --manifest-path crates/wasm/Cargo.toml --bin <name>.
Embedding wasmtime
Web Programming
Scraping Web Pages
Uniform Resource Locations (URL)
Media Types (MIME)
| Recipe | Crates | Categories |
|---|---|---|
| Get MIME type from string | mime | Encoding |
| Get MIME type from filename | mime | Encoding |
| Parse the MIME type of a HTTP response | mime reqwest tokio | Net Encoding |
Clients
Web Authentication
| Recipe | Crates | Categories |
|---|---|---|
| Basic Authentication | reqwest | Net |
Full Stack Web