Serde is a framework forserializing anddeserializing Rust datastructures efficiently and generically.
The Serde ecosystem consists of data structures that know how to serializeand deserialize themselves along with data formats that know how toserialize and deserialize other things. Serde provides the layer by whichthese two groups interact with each other, allowing any supported datastructure to be serialized and deserialized using any supported data format.
See the Serde websitehttps://serde.rs/ for additional documentation andusage examples.
Where many other languages rely on runtime reflection for serializing data,Serde is instead built on Rust’s powerful trait system. A data structurethat knows how to serialize and deserialize itself is one that implementsSerde’sSerialize
andDeserialize
traits (or uses Serde’s deriveattribute to automatically generate implementations at compile time). Thisavoids any overhead of reflection or runtime type information. In fact inmany situations the interaction between data structure and data format canbe completely optimized away by the Rust compiler, leaving Serdeserialization to perform the same speed as a handwritten serializer for thespecific selection of data structure and data format.
The following is a partial list of data formats that have been implementedfor Serde by the community.
Generic data structure deserialization framework.
Generic data structure serialization framework.
Helper macro when implementing theDeserializer
part of a new data formatfor Serde.
Conditional compilation depending on whether Serde is built with support for128-bit integers.
Adata structure that can be deserialized from any data format supportedby Serde.
Adata format that can deserialize any data structure supported bySerde.
Adata structure that can be serialized into any data format supportedby Serde.
Adata format that can serialize any data structure supported by Serde.