@@ -4,12 +4,10 @@ use time::serde;
4
4
use crate :: error;
5
5
use crate :: error:: Result ;
6
6
use crate :: parameters:: Series ;
7
- use crate :: { DATE_FORMAT , DURATION_FORMAT , SHORT_DURATION_FORMAT , TIME_FORMAT } ;
7
+ use crate :: { DATE_FORMAT , TIME_FORMAT } ;
8
8
9
9
serde:: format_description!( date_format, Date , DATE_FORMAT ) ;
10
10
serde:: format_description!( time_format, Time , TIME_FORMAT ) ;
11
- serde:: format_description!( duration_format, Time , DURATION_FORMAT ) ;
12
- serde:: format_description!( short_duration_format, Time , SHORT_DURATION_FORMAT ) ;
13
11
14
12
#[ derive( Debug , Serialize , Deserialize , Default , PartialEq , Eq ) ]
15
13
pub struct Pagination {
@@ -24,7 +22,7 @@ pub struct Response<T> {
24
22
pub data : T ,
25
23
26
24
#[ serde( flatten) ]
27
- #[ serde( skip_serializing_if = "Option::is_none" ) ]
25
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
28
26
pub pagination : Option < Pagination > ,
29
27
pub series : Series ,
30
28
}
@@ -114,10 +112,12 @@ pub enum Standings {
114
112
115
113
#[ derive( Debug , Serialize , Deserialize ) ]
116
114
pub struct LapsResponse {
115
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
117
116
pub url : Option < String > ,
118
117
pub race_name : String ,
119
118
#[ serde( with = "date_format" ) ]
120
119
pub date : time:: Date ,
120
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
121
121
#[ serde( with = "time_format::option" ) ]
122
122
pub time : Option < time:: Time > ,
123
123
@@ -128,10 +128,12 @@ pub struct LapsResponse {
128
128
129
129
#[ derive( Debug , Serialize , Deserialize ) ]
130
130
pub struct PitStopsResponse {
131
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
131
132
pub url : Option < String > ,
132
133
pub race_name : String ,
133
134
#[ serde( with = "date_format" ) ]
134
135
pub date : time:: Date ,
136
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
135
137
#[ serde( with = "time_format::option" ) ]
136
138
pub time : Option < time:: Time > ,
137
139
@@ -147,37 +149,59 @@ pub struct Race {
147
149
pub name : String ,
148
150
#[ serde( with = "date_format" ) ]
149
151
pub date : time:: Date ,
150
- #[ serde( with = "time_format::option" ) ]
152
+ #[ serde(
153
+ skip_serializing_if = "Option::is_none" ,
154
+ with = "time_format::option" ,
155
+ default
156
+ ) ]
151
157
pub time : Option < time:: Time > ,
158
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
152
159
pub url : Option < String > ,
160
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
153
161
pub fp1 : Option < DateAndTime > ,
162
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
154
163
pub fp2 : Option < DateAndTime > ,
164
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
155
165
pub fp3 : Option < DateAndTime > ,
166
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
156
167
pub quali : Option < DateAndTime > ,
168
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
157
169
pub sprint : Option < DateAndTime > ,
158
170
}
159
171
160
172
#[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
161
173
pub struct Circuit {
162
174
pub circuit_ref : String ,
163
175
pub name : String ,
176
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
164
177
pub location : Option < String > ,
178
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
165
179
pub country : Option < String > ,
180
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
166
181
pub lat : Option < f32 > ,
182
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
167
183
pub lng : Option < f32 > ,
184
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
168
185
pub alt : Option < i32 > ,
169
186
pub url : String ,
170
187
}
171
188
172
189
#[ derive( Debug , Serialize , Deserialize ) ]
173
190
pub struct Driver {
174
191
pub driver_ref : String ,
192
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
175
193
pub number : Option < i32 > ,
194
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
176
195
pub code : Option < String > ,
177
196
pub forename : String ,
178
197
pub surname : String ,
179
- #[ serde( with = "date_format::option" ) ]
198
+ #[ serde(
199
+ skip_serializing_if = "Option::is_none" ,
200
+ with = "date_format::option" ,
201
+ default
202
+ ) ]
180
203
pub dob : Option < time:: Date > ,
204
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
181
205
pub nationality : Option < String > ,
182
206
pub url : String ,
183
207
}
@@ -186,14 +210,17 @@ pub struct Driver {
186
210
pub struct Constructor {
187
211
pub constructor_ref : String ,
188
212
pub name : String ,
213
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
189
214
pub nationality : Option < String > ,
190
215
pub url : String ,
191
216
}
192
217
193
218
#[ derive( Debug , Serialize , Deserialize ) ]
194
219
pub struct Standing {
195
220
pub points : f32 ,
221
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
196
222
pub position : Option < i32 > ,
223
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
197
224
pub position_text : Option < String > ,
198
225
pub wins : i32 ,
199
226
}
@@ -215,9 +242,10 @@ pub struct Lap {
215
242
#[ derive( Debug , Serialize , Deserialize ) ]
216
243
pub struct LapTiming {
217
244
pub driver_ref : String ,
245
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
218
246
pub position : Option < i32 > ,
219
- #[ serde( with = "duration_format::option" ) ]
220
- pub time : Option < time :: Time > ,
247
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
248
+ pub time : Option < String > ,
221
249
}
222
250
223
251
#[ derive( Debug , Serialize , Deserialize ) ]
@@ -227,8 +255,8 @@ pub struct PitStop {
227
255
pub stop : i32 ,
228
256
#[ serde( with = "time_format" ) ]
229
257
pub time : time:: Time ,
230
- #[ serde( with = "short_duration_format::option" ) ]
231
- pub duration : Option < time :: Time > ,
258
+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
259
+ pub duration : Option < String > ,
232
260
}
233
261
234
262
#[ derive( Debug , Serialize , Deserialize ) ]
0 commit comments