Custom serialization and deserialization

As we saw before, Serde provides built-in serialization and deserialization for all primitive data types, and a number of complex data types, via macros. In some cases, however, Serde might fail to auto-implement. This might happen for more complex data types. In those cases, you will need to implement these manually. These cases demonstrate advanced usage of Serde, which also allows renaming fields in the output. For everyday usage, using these advanced feature is almost never necessary. These might be more common for networking, to handle a new protocol, and more.

Let's say we have a struct of three fields. We will just assume that Serde fails to implement Serialize and Deserialize on this, and so ...

Get Network Programming with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.