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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use ;
use ;
/// [Postbag codec](postbag) with full forward and backward compatibility.
///
/// Postbag is a high-performance binary codec that provides efficient data encoding
/// with configurable levels of forward and backward compatibility. This codec uses the [`Full`](postbag::cfg::Full)
/// configuration which provides maximum compatibility and schema evolution capabilities.
///
/// ## Key Features
///
/// - **Full fidelity of Rust type system**: Supports all serde-compatible types including
/// structs, enums, tuples, arrays, maps, and all primitive types
/// - **Efficient binary format**: Uses variable-length encoding (varint) for integers,
/// compact representations for common types, and minimal overhead
/// - **Full forward/backward compatibility**: Fields and enum variants can be reordered,
/// added, or removed safely
///
/// ## Forward and Backward Compatibility
///
/// The `Full` configuration provides comprehensive schema evolution capabilities:
///
/// - **Field reordering**: Struct fields can be reordered without breaking compatibility
/// - **Field addition**: New fields can be added to structs at any position
/// - **Field removal**: Existing fields can be removed without affecting deserialization
/// - **Enum variant evolution**: Enum variants can be added, removed, or reordered
/// - **Schema evolution**: Safe evolution of data structures over time
///
/// ## Numerical Identifier Encoding
///
/// Fields named `_0` through `_59` are encoded with just a single byte instead of the full
/// string identifier. Use `#[serde(rename = "...")]` to specify numerical IDs:
///
/// ```rust
/// use serde::{Serialize, Deserialize};
///
/// #[derive(Serialize, Deserialize)]
/// struct CompactData {
/// #[serde(rename = "_3")]
/// my_field: u32,
/// #[serde(rename = "_15")]
/// another_field: String,
/// // Regular field names work normally
/// normal_field: bool,
/// }
/// ```
///
/// This serializes and deserializes *with* field identifiers for maximum compatibility.
;
/// [Postbag slim codec](postbag) for compact, high-performance encoding.
///
/// The [`Slim`](postbag::cfg::Slim) configuration prioritizes performance and compact size over compatibility.
/// This codec provides efficient binary encoding but with limited schema evolution
/// capabilities compared to the full `Postbag` codec.
///
/// ## Key Features
///
/// - **Compact encoding**: Smaller serialized data size compared to `Full` configuration
/// - **Fast processing**: No string lookups during serialization/deserialization
/// - **High performance**: Optimized for speed and minimal overhead
///
/// ## Schema Evolution Limitations
///
/// The `Slim` configuration has limited schema evolution capabilities. **Fields and enum
/// variants must maintain their order** for compatibility.
///
/// ### Supported Changes
///
/// - **Adding fields**: New fields can be added to the **end** of structs only
/// - **Removing fields**: Fields can be removed from the **end** of structs only
/// - **Adding enum variants**: New variants can be added at the **end** of enums only
/// - **Removing enum variants**: Variants can be removed from the **end** of enums only
///
/// ### Important Compatibility Notes
///
/// - Fields and enum variants **cannot be reordered**
/// - Fields and enum variants **cannot be added or removed from the middle**
/// - Use serde defaults (`#[serde(default)]`) for new fields to ensure backward compatibility
/// - Always add new fields at the end of struct definitions
/// - Always add new enum variants at the end of enum definitions
///
/// ## When to Use
///
/// Choose `PostbagSlim` when:
/// - Maximum performance and minimal serialized size are priorities
/// - Schema changes are infrequent or controlled
/// - Data structures have stable field ordering
///
/// Choose the full `Postbag` codec when schema flexibility is more important than
/// the slight performance overhead.
///
/// This serializes and deserializes *without* field identifiers for maximum efficiency.
;