Name Description Size
fmt.rs 4166
impls.rs 30970
impossible.rs This module contains `Impossible` serializer and its implementations. 5295
mod.rs Generic data structure serialization framework. The two most important traits in this module are [`Serialize`] and [`Serializer`]. - **A type that implements `Serialize` is a data structure** that can be serialized to any data format supported by Serde, and conversely - **A type that implements `Serializer` is a data format** that can serialize any data structure supported by Serde. # The Serialize trait Serde provides [`Serialize`] implementations for many Rust primitive and standard library types. The complete list is below. All of these can be serialized using Serde out of the box. Additionally, Serde provides a procedural macro called [`serde_derive`] to automatically generate [`Serialize`] implementations for structs and enums in your program. See the [derive section of the manual] for how to use this. In rare cases it may be necessary to implement [`Serialize`] manually for some type in your program. See the [Implementing `Serialize`] section of the manual for more about this. Third-party crates may provide [`Serialize`] implementations for types that they expose. For example the [`linked-hash-map`] crate provides a [`LinkedHashMap<K, V>`] type that is serializable by Serde because the crate provides an implementation of [`Serialize`] for it. # The Serializer trait [`Serializer`] implementations are provided by third-party crates, for example [`serde_json`], [`serde_yaml`] and [`postcard`]. A partial list of well-maintained formats is given on the [Serde website][data formats]. # Implementations of Serialize provided by Serde - **Primitive types**: - bool - i8, i16, i32, i64, i128, isize - u8, u16, u32, u64, u128, usize - f32, f64 - char - str - &T and &mut T - **Compound types**: - \[T\] - \[T; 0\] through \[T; 32\] - tuples up to size 16 - **Common standard library types**: - String - Option\<T\> - Result\<T, E\> - PhantomData\<T\> - **Wrapper types**: - Box\<T\> - Cow\<'a, T\> - Cell\<T\> - RefCell\<T\> - Mutex\<T\> - RwLock\<T\> - Rc\<T\>&emsp;*(if* features = \["rc"\] *is enabled)* - Arc\<T\>&emsp;*(if* features = \["rc"\] *is enabled)* - **Collection types**: - BTreeMap\<K, V\> - BTreeSet\<T\> - BinaryHeap\<T\> - HashMap\<K, V, H\> - HashSet\<T, H\> - LinkedList\<T\> - VecDeque\<T\> - Vec\<T\> - **FFI types**: - CStr - CString - OsStr - OsString - **Miscellaneous standard library types**: - Duration - SystemTime - Path - PathBuf - Range\<T\> - RangeInclusive\<T\> - Bound\<T\> - num::NonZero* - `!` *(unstable)* - **Net types**: - IpAddr - Ipv4Addr - Ipv6Addr - SocketAddr - SocketAddrV4 - SocketAddrV6 [Implementing `Serialize`]: https://serde.rs/impl-serialize.html [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html [`Serialize`]: ../trait.Serialize.html [`Serializer`]: ../trait.Serializer.html [`postcard`]: https://github.com/jamesmunns/postcard [`linked-hash-map`]: https://crates.io/crates/linked-hash-map [`serde_derive`]: https://crates.io/crates/serde_derive [`serde_json`]: https://github.com/serde-rs/json [`serde_yaml`]: https://github.com/dtolnay/serde-yaml [derive section of the manual]: https://serde.rs/derive.html [data formats]: https://serde.rs/#data-formats 63515