Data Serialization, Deserialization, and Parsing

In the previous chapter, we covered writing simple socket servers in Rust. Transport protocols such as TCP and UDP only provide mechanisms to transport messages, so it is up to a higher-level protocol to actually craft and send those messages. Also, TCP and UDP protocols always deal with bytes; we saw this when we called as_bytes on our strings before sending those out on the socket. This process of converting a piece of data into a format that can be stored or transmitted (a stream of bytes in the case of networking) is called serialization. The reverse process is deserialization, which turns a raw data format into a data structure. Any networking software must deal with serializing and deserializing ...

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.