O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Diesel

Writing a complex application using just low-level libraries is a recipe for a lot of mistakes. Diesel is an ORM and a query builder for Rust. It makes heavy use of derive macros as provided by Macros 1.1. Diesel detects most database interaction mistakes at compile time and is able to produce very efficient code in most cases, sometimes even beating low-level access with C. This is due to its ability to move checks that are typically made at runtime to compile time.

To start with Diesel, we'll need to add Diesel and its code generator library in our Cargo.toml, along with the dotenv library. This library handles the local configuration via dotfiles. We'll use Diesel to store the same person information as with the previous PostgreSQL ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required