Module serde::de [] [src]

Generic data structure deserialization framework.

The two most important traits in this module are Deserialize and Deserializer.

The Deserialize trait

Serde provides Deserialize implementations for many Rust primitive and standard library types. The complete list is below. All of these can be deserialized using Serde out of the box.

Additionally, Serde provides a procedural macro called serde_derive to automatically generate Deserialize implementations for structs and enums in your program. See the codegen section of the manual for how to use this.

In rare cases it may be necessary to implement Deserialize manually for some type in your program. See the Implementing Deserialize section of the manual for more about this.

Third-party crates may provide Deserialize implementations for types that they expose. For example the linked-hash-map crate provides a LinkedHashMap<K, V> type that is deserializable by Serde because the crate provides an implementation of Deserialize for it.

The Deserializer trait

Deserializer implementations are provided by third-party crates, for example serde_json, serde_yaml and bincode.

A partial list of well-maintained formats is given on the Serde website.

Implementations of Deserialize provided by Serde

This is a slightly different set of types than what is supported for serialization. Some types can be serialized by Serde but not deserialized. One example is &str.



This module supports deserializing from primitives with the ValueDeserializer trait.



Unexpected represents an unexpected invocation of any one of the Visitor trait methods.



A data structure that can be deserialized from any data format supported by Serde.


DeserializeSeed is the stateful form of the Deserialize trait. If you ever find yourself looking for a way to pass data into a Deserialize impl, this trait is the way to do it.


A data format that can deserialize any data structure supported by Serde.


EnumVisitor is a visitor that is created by the Deserializer and passed to the Deserialize in order to identify which variant of an enum to deserialize.


The Error trait allows Deserialize implementations to create descriptive error messages belonging to the Deserializer against which they are currently running.


Expected represents an explanation of what data a Visitor was expecting to receive.


MapVisitor visits each item in a sequence.


SeqVisitor visits each item in a sequence.


VariantVisitor is a visitor that is created by the Deserializer and passed to the Deserialize to deserialize the content of a particular enum variant.


This trait represents a visitor that walks through a deserializer.