The serde crate
When I started to use Rust in my projects, I used to use the popular rustc_serialize crate. This wasn't bad, but I found that it wasn't flexible enough. For example, I couldn't use generic data types in my own structs. The serde crate was created to eliminate the shortcomings of the rustc_serialize crate. serde has been the main crate for serialization and deserialization in Rust since the serde crate reached the 1.0 release branch.
We used this crate in the previous chapter to deserialize a configuration file. We're now going to use it to transform request and response data to text or binary data.
To explore serialization, we'll use a microservice that generates random numbers. We'll rewrite a very simple version without ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access