@@ -46,11 +46,7 @@ pub(crate) struct ConnectionPoolOptions {
4646
4747 /// Interval between background thread maintenance runs (e.g. ensure minPoolSize).
4848 #[ cfg( test) ]
49- #[ serde(
50- default ,
51- rename = "backgroundThreadIntervalMS" ,
52- deserialize_with = "BackgroundThreadInterval::deserialize_from_i64_millis"
53- ) ]
49+ #[ serde( rename = "backgroundThreadIntervalMS" ) ]
5450 pub ( crate ) background_thread_interval : Option < BackgroundThreadInterval > ,
5551
5652 /// Connections that have been ready for usage in the pool for longer than `max_idle_time` will
@@ -132,26 +128,19 @@ pub(crate) enum BackgroundThreadInterval {
132128}
133129
134130#[ cfg( test) ]
135- impl BackgroundThreadInterval {
136- pub ( crate ) fn deserialize_from_i64_millis < ' de , D > (
137- deserializer : D ,
138- ) -> std:: result:: Result < Option < Self > , D :: Error >
131+ impl < ' de > Deserialize < ' de > for BackgroundThreadInterval {
132+ fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
139133 where
140134 D : Deserializer < ' de > ,
141135 {
142- let millis = Option :: < i64 > :: deserialize ( deserializer) ?;
143- let millis = if let Some ( m) = millis {
144- m
145- } else {
146- return Ok ( None ) ;
147- } ;
148- Ok ( Some ( match millis. cmp ( & 0 ) {
136+ let millis = i64:: deserialize ( deserializer) ?;
137+ Ok ( match millis. cmp ( & 0 ) {
149138 Ordering :: Less => BackgroundThreadInterval :: Never ,
150139 Ordering :: Equal => return Err ( D :: Error :: custom ( "zero is not allowed" ) ) ,
151140 Ordering :: Greater => {
152141 BackgroundThreadInterval :: Every ( Duration :: from_millis ( millis as u64 ) )
153142 }
154- } ) )
143+ } )
155144 }
156145}
157146
0 commit comments