1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! # Serde Many
//!
//! Serde Many enables multiple serialization/deserialization implementations for the same type.
//!
//! The design ensures seamless integration with the [serde] crate.
//!
//! # Design
//!
//! The core design of this crate revolves around the `SerializeMany` and `DeserializeMany` traits.
//! These traits are similar to serde's `Serialize` and `Deserialize` traits,
//! but are generic over a marker type, allowing multiple implementations for different markers.
//!
//! To ensure seamless integration with serde, any type that implements serde's
//! `Serialize` and `Deserialize` automatically implements
//! `SerializeMany` and `DeserializeMany` for all markers. This means that types which
//! manually implement `SerializeMany` and `DeserializeMany` cannot also implement
//! serde's `Serialize` and `Deserialize`.
//!
//! # Derive
//!
//! Implementing serialization and deserialization by hand can be tedious. To simplify this process,
//! this crate (with the "derive" feature) provides derive macros to automatically generate implementations
//! of the `SerializeMany` and `DeserializeMany` traits.
//!
//! The derive macros use the actual serde derive macros under the hood, meaning all of
//! serde's attributes are supported.
//!
//! ## Example
//! ```
//! use serde_many::{DeserializeMany, SerializeMany};
//!
//! /// Marker for the default serde implementation.
//! struct Default;
//!
//! /// Marker for a special serde implementation.
//! struct Special;
//!
//! # #[cfg(feature = "derive")]
//! #[derive(SerializeMany, DeserializeMany)]
//! #[serde_many(default = "Default", special = "Special")] // Declaring the implementation markers.
//! struct Point {
//! #[serde(special(rename = "x_value"))]
//! x: i32,
//! #[serde(special(rename = "y_value"))]
//! y: i32,
//! }
//! ```
pub use AsSerde;
use ;
pub use ;
/// A trait for serializing a value with a specific marker type.
/// A trait for deserializing a value with a specific marker type.
// Default implementation of `SerializeMany` for any type that implements `Serialize`.
// Default implementation of `DeserializeMany` for any type that implements `Deserialize`.