@@ -176,7 +176,12 @@ pub struct PushConfig {
176176 pub read_only : bool ,
177177}
178178
179- #[ derive( Deserialize , Serialize , Debug , Default ) ]
179+ // From https://github.com/serde-rs/serde/issues/818#issuecomment-287438544
180+ fn default < T : Default + PartialEq > ( t : & T ) -> bool {
181+ * t == Default :: default ( )
182+ }
183+
184+ #[ derive( Deserialize , Serialize , Debug , Default , PartialEq , Eq ) ]
180185#[ serde( deny_unknown_fields) ]
181186pub struct ByteStreamConfig {
182187 /// Name of the store in the "stores" configuration.
@@ -188,7 +193,11 @@ pub struct ByteStreamConfig {
188193 ///
189194 ///
190195 /// Default: 64KiB
191- #[ serde( default , deserialize_with = "convert_data_size_with_shellexpand" ) ]
196+ #[ serde(
197+ default ,
198+ deserialize_with = "convert_data_size_with_shellexpand" ,
199+ skip_serializing_if = "default"
200+ ) ]
192201 pub max_bytes_per_stream : usize ,
193202
194203 /// In the event a client disconnects while uploading a blob, we will hold
@@ -197,7 +206,11 @@ pub struct ByteStreamConfig {
197206 /// the same blob.
198207 ///
199208 /// Default: 10 (seconds)
200- #[ serde( default , deserialize_with = "convert_duration_with_shellexpand" ) ]
209+ #[ serde(
210+ default ,
211+ deserialize_with = "convert_duration_with_shellexpand" ,
212+ skip_serializing_if = "default"
213+ ) ]
201214 pub persist_stream_on_disconnect_timeout : usize ,
202215}
203216
@@ -208,11 +221,23 @@ pub struct ByteStreamConfig {
208221#[ serde( deny_unknown_fields) ]
209222pub struct OldByteStreamConfig {
210223 pub cas_stores : HashMap < InstanceName , StoreRefName > ,
211- #[ serde( default , deserialize_with = "convert_data_size_with_shellexpand" ) ]
224+ #[ serde(
225+ default ,
226+ deserialize_with = "convert_data_size_with_shellexpand" ,
227+ skip_serializing_if = "default"
228+ ) ]
212229 pub max_bytes_per_stream : usize ,
213- #[ serde( default , deserialize_with = "convert_data_size_with_shellexpand" ) ]
230+ #[ serde(
231+ default ,
232+ deserialize_with = "convert_data_size_with_shellexpand" ,
233+ skip_serializing_if = "default"
234+ ) ]
214235 pub max_decoding_message_size : usize ,
215- #[ serde( default , deserialize_with = "convert_duration_with_shellexpand" ) ]
236+ #[ serde(
237+ default ,
238+ deserialize_with = "convert_duration_with_shellexpand" ,
239+ skip_serializing_if = "default"
240+ ) ]
216241 pub persist_stream_on_disconnect_timeout : usize ,
217242}
218243
0 commit comments