@@ -46,11 +46,7 @@ pub(crate) struct ConnectionPoolOptions {
46
46
47
47
/// Interval between background thread maintenance runs (e.g. ensure minPoolSize).
48
48
#[ cfg( test) ]
49
- #[ serde(
50
- default ,
51
- rename = "backgroundThreadIntervalMS" ,
52
- deserialize_with = "BackgroundThreadInterval::deserialize_from_i64_millis"
53
- ) ]
49
+ #[ serde( rename = "backgroundThreadIntervalMS" ) ]
54
50
pub ( crate ) background_thread_interval : Option < BackgroundThreadInterval > ,
55
51
56
52
/// 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 {
132
128
}
133
129
134
130
#[ 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 >
139
133
where
140
134
D : Deserializer < ' de > ,
141
135
{
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 ) {
149
138
Ordering :: Less => BackgroundThreadInterval :: Never ,
150
139
Ordering :: Equal => return Err ( D :: Error :: custom ( "zero is not allowed" ) ) ,
151
140
Ordering :: Greater => {
152
141
BackgroundThreadInterval :: Every ( Duration :: from_millis ( millis as u64 ) )
153
142
}
154
- } ) )
143
+ } )
155
144
}
156
145
}
157
146
0 commit comments