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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
use super::*;
mod impls;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct FlightFree {
/// ICAO24 Hex address.
pub hex: Option<String>,
/// Aircraft Registration Number
pub reg_number: Option<String>,
/// Aircraft ICAO type. Available in the Free plan.
pub aircraft_icao: Option<String>,
/// ISO 2 country code from Countries DB. Available in the Free plan.
pub flag: String,
/// Aircraft Geo-Latitude for now. Available in the Free plan.
pub lat: Option<f64>,
/// Aircraft Geo-Longitude for now. Available in the Free plan.
pub lng: Option<f64>,
/// Aircraft elevation for now (meters).
pub alt: Option<u64>,
/// Aircraft head direction for now. Available in the Free plan.
pub dir: Option<f64>,
/// Aircraft horizontal speed (km) for now.
pub speed: Option<u64>,
/// Aircraft vertical speed (km) for now.
pub v_speed: Option<u64>,
/// Aircraft squawk signal code.
pub squawk: Option<String>,
/// Airline IATA code. Available in the Free plan.
pub airline_iata: String,
/// Airline ICAO code.
pub airline_icao: String,
/// Flight IATA code-number. Available in the Free plan.
pub flight_iata: String,
/// Flight ICAO code-number.
pub flight_icao: String,
/// Flight number only. Available in the Free plan.
pub flight_number: String,
/// Codeshared airline IATA code.
pub cs_airline_iata: Option<String>,
/// Codeshared flight IATA code-number.
pub cs_flight_iata: Option<String>,
/// Codeshared flight number.
pub cs_flight_number: Option<String>,
/// Departure airport IATA code. Available in the Free plan.
pub dep_iata: String,
/// Departure airport ICAO code.
pub dep_icao: String,
/// Estimated departure terminal.
pub dep_terminal: Option<String>,
/// Estimated departure gate.
pub dep_gate: Option<String>,
/// Departure time in the airport time zone. Available in the Free plan.
pub dep_time: String,
/// Departure UNIX timestamp.
pub dep_time_ts: u64,
/// Departure time in UTC time zone.
pub dep_time_utc: String,
/// Updated departure time in the airport time zone.
pub dep_estimated: Option<String>,
/// Updated departure UNIX timestamp.
pub dep_estimated_ts: Option<u64>,
/// Updated departure time in UTC time zone.
pub dep_estimated_utc: Option<String>,
/// Arrival airport IATA code. Available in the Free plan.
pub arr_iata: String,
/// Arrival airport ICAO code.
pub arr_icao: String,
/// Estimated arrival terminal.
pub arr_terminal: Option<String>,
/// Estimated arrival gate.
pub arr_gate: Option<String>,
/// Arrival baggage claim carousel number.
pub arr_baggage: Option<String>,
/// Arrival time in the airport time zone. Available in the Free plan.
pub arr_time: String,
/// Arrival UNIX timestamp.
pub arr_time_ts: u64,
/// Arrival time in UTC time zone.
pub arr_time_utc: String,
/// Updated arrival time in the airport time zone.
pub arr_estimated: Option<String>,
/// Updated arrival UNIX timestamp.
pub arr_estimated_ts: Option<u64>,
/// Updated arrival time in UTC time zone.
pub arr_estimated_utc: Option<String>,
/// Estimated flight time (in minutes).
pub duration: u64,
/// (deprecated) Estimated flight delay time (in minutes).
pub delayed: Option<u64>,
/// Estimated time of flight departure delay (in minutes).
pub dep_delayed: Option<u64>,
/// Estimated time of flight arrival delay (in minutes).
pub arr_delayed: Option<u64>,
/// UNIX timestamp of last aircraft signal.
pub updated: u64,
/// Current flight status - scheduled, en-route, landed.
pub status: String,
/// Aircraft full model name.
pub model: Option<String>,
/// Aircraft manufacturer name. Available in the Free plan.
pub manufacturer: Option<String>,
/// Manufacturer serial number.
pub msn: Option<String>,
/// Aircraft type - landplane, seaplane, tiltrotor, helicopter, gyrocopter, amphibian.
pub r#type: Option<AircraftType>,
/// Aircraft engine type - jet, piston, turboprop/turboshaft, electric.
pub engine: Option<String>,
/// Aircraft engine number - 1, 2, 3, 4, 6, 8
pub engine_count: Option<String>,
/// Aircraft built year
pub built: Option<u64>,
/// Aircraft age (years)
pub age: Option<u64>,
// Next fields are present in the response, but not documented
/// Airline name. Available in the Free plan.
pub airline_name: Option<String>,
/// Departure airport name
pub dep_name: Option<String>,
/// Departure city
pub dep_city: Option<String>,
/// Departure country
pub dep_country: Option<String>,
/// Actual departure time in the airport time zone.
pub dep_actual: Option<String>,
/// Actual departure time UNIX timestamp.
pub dep_actual_ts: Option<u64>,
/// Actual departure time in the UTC time zone.
pub dep_actual_utc: Option<String>,
/// Arrival airport name
pub arr_name: Option<String>,
/// Arrival city
pub arr_city: Option<String>,
/// Arrival country
pub arr_country: Option<String>,
/// Actual arrival time in the airport time zone.
pub arr_actual: Option<String>,
/// Actual arrival time UNIX timestamp.
pub arr_actual_ts: Option<u64>,
/// Actual arrival time in the UTC time zone.
pub arr_actual_utc: Option<String>,
/// ETA (in minutes).
pub eta: Option<u64>,
/// Don't know what this is
pub percent: Option<u64>,
/// Response time in UTC timezone
pub utc: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Flight {
/// ICAO24 Hex address.
pub hex: Option<String>,
/// Aircraft Registration Number
pub reg_number: String,
/// Aircraft ICAO type. Available in the Free plan.
pub aircraft_icao: Option<String>,
/// ISO 2 country code from Countries DB. Available in the Free plan.
pub flag: String,
/// Aircraft Geo-Latitude for now. Available in the Free plan.
pub lat: Option<f64>,
/// Aircraft Geo-Longitude for now. Available in the Free plan.
pub lng: Option<f64>,
/// Aircraft elevation for now (meters).
pub alt: Option<u64>,
/// Aircraft head direction for now. Available in the Free plan.
pub dir: Option<f64>,
/// Aircraft horizontal speed (km) for now.
pub speed: Option<u64>,
/// Aircraft vertical speed (km) for now.
pub v_speed: Option<u64>,
/// Aircraft squawk signal code.
pub squawk: Option<String>,
/// Airline IATA code. Available in the Free plan.
pub airline_iata: String,
/// Airline ICAO code.
pub airline_icao: String,
/// Flight IATA code-number. Available in the Free plan.
pub flight_iata: String,
/// Flight ICAO code-number.
pub flight_icao: String,
/// Flight number only. Available in the Free plan.
pub flight_number: String,
/// Codeshared airline IATA code.
pub cs_airline_iata: Option<String>,
/// Codeshared flight IATA code-number.
pub cs_flight_iata: Option<String>,
/// Codeshared flight number.
pub cs_flight_number: Option<String>,
/// Departure airport IATA code. Available in the Free plan.
pub dep_iata: String,
/// Departure airport ICAO code.
pub dep_icao: String,
/// Estimated departure terminal.
pub dep_terminal: Option<String>,
/// Estimated departure gate.
pub dep_gate: Option<String>,
/// Departure time in the airport time zone. Available in the Free plan.
pub dep_time: String,
/// Departure UNIX timestamp.
pub dep_time_ts: u64,
/// Departure time in UTC time zone.
pub dep_time_utc: String,
/// Updated departure time in the airport time zone.
pub dep_estimated: Option<String>,
/// Updated departure UNIX timestamp.
pub dep_estimated_ts: Option<u64>,
/// Updated departure time in UTC time zone.
pub dep_estimated_utc: Option<String>,
/// Arrival airport IATA code. Available in the Free plan.
pub arr_iata: String,
/// Arrival airport ICAO code.
pub arr_icao: String,
/// Estimated arrival terminal.
pub arr_terminal: Option<String>,
/// Estimated arrival gate.
pub arr_gate: Option<String>,
/// Arrival baggage claim carousel number.
pub arr_baggage: Option<String>,
/// Arrival time in the airport time zone. Available in the Free plan.
pub arr_time: String,
/// Arrival UNIX timestamp.
pub arr_time_ts: u64,
/// Arrival time in UTC time zone.
pub arr_time_utc: String,
/// Updated arrival time in the airport time zone.
pub arr_estimated: Option<String>,
/// Updated arrival UNIX timestamp.
pub arr_estimated_ts: Option<u64>,
/// Updated arrival time in UTC time zone.
pub arr_estimated_utc: Option<String>,
/// Estimated flight time (in minutes).
pub duration: u64,
/// (deprecated) Estimated flight delay time (in minutes).
pub delayed: Option<u64>,
/// Estimated time of flight departure delay (in minutes).
pub dep_delayed: Option<u64>,
/// Estimated time of flight arrival delay (in minutes).
pub arr_delayed: Option<u64>,
/// UNIX timestamp of last aircraft signal.
pub updated: u64,
/// Current flight status - scheduled, en-route, landed.
pub status: String,
/// Aircraft full model name.
pub model: Option<String>,
/// Aircraft manufacturer name. Available in the Free plan.
pub manufacturer: Option<String>,
/// Manufacturer serial number.
pub msn: Option<String>,
/// Aircraft type - landplane, seaplane, tiltrotor, helicopter, gyrocopter, amphibian.
pub r#type: Option<AircraftType>,
/// Aircraft engine type - jet, piston, turboprop/turboshaft, electric.
pub engine: String,
/// Aircraft engine number - 1, 2, 3, 4, 6, 8
pub engine_count: String,
/// Aircraft built year
pub built: Option<u64>,
/// Aircraft age (years)
pub age: Option<u64>,
// Next fields are present in the response, but not documented
/// Airline name. Available in the Free plan.
pub airline_name: Option<String>,
/// Departure airport name
pub dep_name: Option<String>,
/// Departure city
pub dep_city: Option<String>,
/// Departure country
pub dep_country: Option<String>,
/// Actual departure time in the airport time zone.
pub dep_actual: Option<String>,
/// Actual departure time UNIX timestamp.
pub dep_actual_ts: Option<u64>,
/// Actual departure time in the UTC time zone.
pub dep_actual_utc: Option<String>,
/// Arrival airport name
pub arr_name: Option<String>,
/// Arrival city
pub arr_city: Option<String>,
/// Arrival country
pub arr_country: Option<String>,
/// Actual arrival time in the airport time zone.
pub arr_actual: Option<String>,
/// Actual arrival time UNIX timestamp.
pub arr_actual_ts: Option<u64>,
/// Actual arrival time in the UTC time zone.
pub arr_actual_utc: Option<String>,
/// ETA (in minutes).
pub eta: Option<u64>,
/// Don't know what this is
pub percent: Option<u64>,
/// Response time in UTC timezone
pub utc: Option<String>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AircraftType {
Adsb,
Landplane,
Seaplane,
Tiltrotor,
Helicopter,
Gyrocopter,
Amphibian,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct FlightRequest {
api_key: String,
#[serde(flatten)]
pub code: FlightCode,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum FlightCode {
#[serde(rename = "flight_iata")]
Iata(String),
#[serde(rename = "flight_icao")]
Icao(String),
}
impl AirLabsRequest for FlightRequest {
type Response = Flight;
type ResponseFree = FlightFree;
const METHOD: &'static str = "flight";
}
#[cfg(test)]
mod tests;