This chapter is sort of a cookbook of some of the most popular external crates. These crates are so common that you can almost think of them as extensions of the standard library—they’re not just random crates sitting around that nobody uses. Learning just these few crates will allow you to turn data like JSON into Rust structs, work with time and time zones, handle errors with less code, speed up your code, and work with global statics.
You’ll also learn about blanket trait implementations, which are extremely fun. With those, you can give your trait methods to other people’s types even if they didn’t ask for them!
The serde crate is an extremely popular crate that lets you convert to and from formats like JSON, YAML, and so on. In fact, it’s so popular that it’s rare to find a Rust programmer who has never heard of it.
JSON is one of the most common ways to send requests and receive information online, and it’s is pretty simple, being made up of keys and values. Here is what it looks like:
{ "name":"BillyTheUser", "id":6876 }