rust_flightplan 1.1.1

Loads a flight plan from SimBrief and decodes it.
Documentation
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
////////////////////////////////////////////////////////////////////////////////////////////////////
// MIT License                                                                                     /
//                                                                                                 /
// Copyright (c) 2024 Rust-FlightPlan Team                                                         /
//                                                                                                 /
// Permission is hereby granted, free of charge, to any person obtaining a copy                    /
// of this software and associated documentation files (the "Software"), to deal                   /
// in the Software without restriction, including without limitation the rights                    /
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell                       /
// copies of the Software, and to permit persons to whom the Software is                           /
// furnished to do so, subject to the following conditions:                                        /
//                                                                                                 /
// The above copyright notice and this permission notice shall be included in all                  /
// copies or substantial portions of the Software.                                                 /
//                                                                                                 /
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR                      /
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,                        /
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE                     /
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER                          /
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,                   /
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE                   /
// SOFTWARE.                                                                                       /
////////////////////////////////////////////////////////////////////////////////////////////////////

use crate::converter::bool_from_str;
use crate::converter::f32_from_str;
use crate::converter::f64_from_str;
use crate::converter::i16_from_str;
use crate::converter::i32_from_str;
use crate::converter::i8_from_str;
use crate::converter::option_f64_from_str;
use crate::converter::option_i8_from_str_wind_comp;
use crate::converter::option_u16_from_str;
use crate::converter::option_u32_from_str;
use crate::converter::option_u8_from_str;
use crate::converter::ts_from_string;
use crate::converter::u16_from_str;
use crate::converter::u32_from_str;
use crate::converter::u8_from_str;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Ofp {
    pub fetch: Fetch,
    pub params: Params,
    pub general: General,
    pub origin: Airport,
    pub destination: Airport,
    #[serde(alias = "alternate")]
    pub alternates: Option<Vec<Airport>>,
    pub takeoff_altn: Option<Airport>,
    pub enroute_altn: Option<Airport>,
    pub navlog: Option<Navlog>,
    pub etops: Option<Etops>,
    pub tlr: Option<Tlr>,
    pub atc: Option<Atc>,
    pub aircraft: Aircraft,
    pub fuel: Fuel,
    pub fuel_extra: FuelExtra,
    pub times: Times,
    pub weights: Weights,
    pub impacts: Option<Impacts>,
    pub crew: Crew,
    pub notams: Option<Notams>,
    pub weather: Weather,
    pub sigmets: Option<Sigmets>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Fetch {
    #[serde(alias = "userid", deserialize_with = "u32_from_str")]
    pub user_id: u32,
    pub static_id: Option<String>,
    pub status: String,
    #[serde(deserialize_with = "f32_from_str")]
    pub time: f32,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Params {
    #[serde(deserialize_with = "u32_from_str")]
    pub request_id: u32,
    pub sequence_id: String,
    #[serde(deserialize_with = "u32_from_str")]
    pub user_id: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub time_generated: u32,
    pub static_id: Option<String>,
    pub xml_file: String,
    pub ofp_layout: String,
    pub airac: String,
    pub units: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct General {
    #[serde(deserialize_with = "u8_from_str")]
    pub release: u8,
    pub icao_airline: String,
    pub flight_number: String,
    #[serde(deserialize_with = "bool_from_str")]
    pub is_etops: bool,
    pub dx_rmk: Vec<String>,
    pub sys_rmk: Option<String>,
    #[serde(deserialize_with = "bool_from_str")]
    pub is_detailed_profile: bool,
    pub cruise_profile: String,
    pub climb_profile: String,
    pub descent_profile: String,
    pub alternate_profile: String,
    pub reserve_profile: String,
    #[serde(deserialize_with = "u16_from_str")]
    pub costindex: u16,
    pub cont_rule: String,
    #[serde(deserialize_with = "u16_from_str")]
    pub initial_altitude: u16,
    pub stepclimb_string: String,
    #[serde(deserialize_with = "i8_from_str")]
    pub avg_temp_dev: i8,
    #[serde(deserialize_with = "u16_from_str")]
    pub avg_tropopause: u16,
    #[serde(deserialize_with = "i8_from_str")]
    pub avg_wind_comp: i8,
    #[serde(deserialize_with = "u16_from_str")]
    pub avg_wind_dir: u16,
    #[serde(deserialize_with = "u8_from_str")]
    pub avg_wind_spd: u8,
    #[serde(deserialize_with = "u16_from_str")]
    pub gc_distance: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub route_distance: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub air_distance: u16,
    #[serde(deserialize_with = "u32_from_str")]
    pub total_burn: u32,
    #[serde(deserialize_with = "u16_from_str")]
    pub cruise_tas: u16,
    pub cruise_mach: String,
    #[serde(deserialize_with = "u16_from_str")]
    pub passengers: u16,
    pub route: String,
    pub route_ifps: String,
    pub route_navigraph: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Airport {
    pub icao_code: String,
    pub iata_code: String,
    pub faa_code: Option<String>,
    pub icao_region: String,
    #[serde(deserialize_with = "i16_from_str")]
    pub elevation: i16,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_lat: f64,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_long: f64,
    pub name: String,
    #[serde(deserialize_with = "i8_from_str")]
    pub timezone: i8,
    pub plan_rwy: Option<String>,
    #[serde(deserialize_with = "u16_from_str")]
    pub trans_alt: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub trans_level: u16,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub cruise_altitude: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub distance: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub gc_distance: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub air_distance: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub track_true: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub track_mag: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub tas: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub gs: Option<u16>,
    #[serde(default, deserialize_with = "option_i8_from_str_wind_comp")]
    pub avg_wind_comp: Option<i8>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub avg_wind_dir: Option<u16>,
    #[serde(default, deserialize_with = "option_u8_from_str")]
    pub avg_wind_spd: Option<u8>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub avg_tropopause: Option<u16>,
    pub avg_tdv: Option<String>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub ete: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub burn: Option<u16>,
    pub route: Option<String>,
    pub route_ifps: Option<String>,
    pub metar: String,
    pub metar_time: Option<DateTime<Utc>>,
    pub metar_category: Option<String>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub metar_visibility: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub metar_ceiling: Option<u16>,
    pub taf: String,
    pub taf_time: Option<DateTime<Utc>>,
    pub atis: Option<Vec<Atis>>,
    pub notam: Option<Vec<Notam>>,
    pub fcst_cig: Option<String>,
    pub fcst_vis: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Atis {
    pub network: String,
    pub issued: Option<DateTime<Utc>>,
    pub letter: Option<String>,
    pub phonetic: Option<String>,
    #[serde(alias = "type")]
    pub variant: String,
    pub message: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Notam {
    pub source_id: String,
    pub account_id: String,
    #[serde(alias = "notam_id")]
    pub id: String,
    pub location_id: String,
    pub location_icao: String,
    pub location_name: String,
    pub location_type: String,
    pub date_created: DateTime<Utc>,
    pub date_effective: DateTime<Utc>,
    pub date_expire: Option<DateTime<Utc>>,
    #[serde(default, deserialize_with = "bool_from_str")]
    pub date_expire_is_estimated: bool,
    pub date_modified: DateTime<Utc>,
    #[serde(alias = "notam_schedule")]
    pub schedule: Option<String>,
    #[serde(alias = "notam_html")]
    pub html: String,
    #[serde(alias = "notam_text")]
    pub text: String,
    #[serde(alias = "notam_raw")]
    pub raw: String,
    #[serde(alias = "notam_nrc")]
    pub nrc: String,
    #[serde(alias = "notam_qcode")]
    pub qcode: Option<String>,
    #[serde(alias = "notam_qcode_category")]
    pub qcode_category: String,
    #[serde(alias = "notam_qcode_subject")]
    pub qcode_subject: Option<String>,
    #[serde(alias = "notam_qcode_status")]
    pub qcode_status: Option<String>,
    #[serde(
        default,
        alias = "notam_is_obstacle",
        deserialize_with = "bool_from_str"
    )]
    pub is_obstacle: bool,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Navlog {
    #[serde(alias = "fix")]
    pub fixes: Vec<Fix>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Fix {
    pub ident: String,
    pub name: String,
    #[serde(alias = "type")]
    pub variant: String,
    pub icao_region: Option<String>,
    #[serde(default, deserialize_with = "option_f64_from_str")]
    pub frequency: Option<f64>,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_lat: f64,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_long: f64,
    pub stage: String,
    pub via_airway: String,
    #[serde(deserialize_with = "bool_from_str")]
    pub is_sid_star: bool,
    #[serde(deserialize_with = "u16_from_str")]
    pub distance: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub track_true: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub track_mag: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub heading_true: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub heading_mag: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub altitude_feet: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub ind_airspeed: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub true_airspeed: u16,
    pub mach: String,
    pub mach_thousandths: String,
    #[serde(deserialize_with = "i8_from_str")]
    pub wind_component: i8,
    #[serde(deserialize_with = "u16_from_str")]
    pub groundspeed: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub time_leg: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub time_total: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub fuel_flow: u16,
    #[serde(deserialize_with = "u32_from_str")]
    pub fuel_leg: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub fuel_totalused: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub fuel_min_onboard: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub fuel_plan_onboard: u32,
    #[serde(deserialize_with = "i8_from_str")]
    pub oat: i8,
    #[serde(deserialize_with = "i8_from_str")]
    pub oat_isa_dev: i8,
    #[serde(deserialize_with = "u16_from_str")]
    pub wind_dir: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub wind_spd: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub shear: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub tropopause_feet: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub ground_height: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub mora: u16,
    pub fir: String,
    pub fir_units: String,
    pub fir_valid_levels: String,
    pub wind_data: FixWind,
    pub fir_crossing: Option<FirCrossing>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FixWind {
    pub level: Vec<FixWindLevel>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FixWindLevel {
    #[serde(deserialize_with = "u16_from_str")]
    pub altitude: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub wind_dir: u16,
    #[serde(deserialize_with = "u8_from_str")]
    pub wind_spd: u8,
    #[serde(deserialize_with = "i8_from_str")]
    pub oat: i8,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FirCrossing {
    pub fir: Vec<Fir>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Fir {
    #[serde(alias = "fir_icao")]
    pub icao: String,
    #[serde(alias = "fir_name")]
    pub name: String,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_lat_entry: f64,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_long_entry: f64,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Etops {
    pub rule: String,
    pub entry: EtopsAirport,
    pub exit: EtopsAirport,
    pub suitable_airport: Vec<Airport>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EtopsAirport {
    pub icao_code: String,
    pub iata_code: String,
    pub faa_code: Option<String>,
    pub icao_region: String,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_lat_apt: f64,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_long_apt: f64,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_lat_fix: f64,
    #[serde(deserialize_with = "f64_from_str")]
    pub pos_long_fix: f64,
    #[serde(deserialize_with = "u16_from_str")]
    pub elapsed_time: u16,
    #[serde(deserialize_with = "u32_from_str")]
    pub min_fob: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub est_fob: u32,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Tlr {
    pub takeoff: TlrContainer,
    pub landing: TlrContainer,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TlrContainer {
    pub conditions: TlrConditions,
    pub distance_dry: Option<TlrDistance>,
    pub distance_wet: Option<TlrDistance>,
    pub runway: Vec<TlrRunway>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TlrConditions {
    pub airport_icao: String,
    pub planned_runway: String,
    #[serde(deserialize_with = "u32_from_str")]
    pub planned_weight: u32,
    #[serde(deserialize_with = "u16_from_str")]
    pub wind_direction: u16,
    #[serde(deserialize_with = "u8_from_str")]
    pub wind_speed: u8,
    #[serde(deserialize_with = "i8_from_str")]
    pub temperature: i8,
    #[serde(deserialize_with = "f64_from_str")]
    pub altimeter: f64,
    pub surface_condition: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TlrRunway {
    pub identifier: String,
    #[serde(deserialize_with = "u16_from_str")]
    pub length: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub length_tora: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub length_toda: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub length_asda: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub length_lda: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub elevation: u16,
    #[serde(deserialize_with = "f64_from_str")]
    pub gradient: f64,
    #[serde(deserialize_with = "u16_from_str")]
    pub true_course: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub magnetic_course: u16,
    #[serde(deserialize_with = "i8_from_str")]
    pub headwind_component: i8,
    #[serde(deserialize_with = "i8_from_str")]
    pub crosswind_component: i8,
    #[serde(default, deserialize_with = "option_f64_from_str")]
    pub ils_frequency: Option<f64>,
    pub flap_setting: Option<String>,
    pub thrust_setting: Option<String>,
    pub bleed_setting: Option<String>,
    pub anti_ice_setting: Option<String>,
    #[serde(default, deserialize_with = "option_u8_from_str")]
    pub flex_temperature: Option<u8>,
    #[serde(default, deserialize_with = "option_u8_from_str")]
    pub max_temperature: Option<u8>,
    #[serde(default, deserialize_with = "option_u32_from_str")]
    pub max_weight: Option<u32>,
    pub limit_code: Option<String>,
    pub limit_obstacle: Option<String>,
    #[serde(default, deserialize_with = "option_u8_from_str")]
    pub speeds_v1: Option<u8>,
    #[serde(default, deserialize_with = "option_u8_from_str")]
    pub speeds_vr: Option<u8>,
    #[serde(default, deserialize_with = "option_u8_from_str")]
    pub speeds_v2: Option<u8>,
    #[serde(default, deserialize_with = "option_u8_from_str")]
    pub speeds_other: Option<u8>,
    pub speeds_other_id: Option<String>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub distance_decide: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub distance_reject: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub distance_margin: Option<u16>,
    #[serde(default, deserialize_with = "option_u16_from_str")]
    pub distance_continue: Option<u16>,
    #[serde(default, deserialize_with = "option_u32_from_str")]
    pub max_weight_dry: Option<u32>,
    #[serde(default, deserialize_with = "option_u32_from_str")]
    pub max_weight_wet: Option<u32>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TlrDistance {
    #[serde(deserialize_with = "u32_from_str")]
    pub weight: u32,
    pub flap_setting: String,
    pub brake_setting: String,
    pub reverser_credit: String,
    #[serde(default, deserialize_with = "option_u8_from_str")]
    pub speeds_vref: Option<u8>,
    #[serde(deserialize_with = "u16_from_str")]
    pub actual_distance: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub factored_distance: u16,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Atc {
    pub flightplan_text: String,
    pub route: String,
    pub route_ifps: String,
    pub callsign: String,
    pub initial_spd: String,
    pub initial_spd_unit: String,
    pub initial_alt: String,
    pub initial_alt_unit: String,
    pub section18: String,
    pub fir_orig: String,
    pub fir_dest: String,
    pub fir_altn: Option<Vec<String>>,
    pub fir_etops: Option<Vec<String>>,
    pub fir_enroute: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Aircraft {
    pub icaocode: String,
    pub iatacode: String,
    pub base_type: String,
    pub icao_code: String,
    pub iata_code: String,
    pub name: Option<String>,
    pub reg: String,
    pub fin: Option<String>,
    pub selcal: Option<String>,
    pub equip: Option<String>,
    pub fuelfact: String,
    pub fuelfactor: String,
    #[serde(deserialize_with = "u16_from_str")]
    pub max_passengers: u16,
    pub supports_tlr: String,
    pub internal_id: String,
    #[serde(deserialize_with = "bool_from_str")]
    pub is_custom: bool,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Fuel {
    #[serde(deserialize_with = "u32_from_str")]
    pub taxi: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub enroute_burn: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub contingency: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub alternate_burn: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub reserve: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub etops: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub extra: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub extra_required: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub extra_optional: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub min_takeoff: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub plan_takeoff: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub plan_ramp: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub plan_landing: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub avg_fuel_flow: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub max_tanks: u32,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FuelExtra {
    pub bucket: Vec<FuelBucket>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FuelBucket {
    pub label: String,
    #[serde(deserialize_with = "u32_from_str")]
    pub fuel: u32,
    #[serde(deserialize_with = "u16_from_str")]
    pub time: u16,
    pub required: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Times {
    #[serde(deserialize_with = "u16_from_str")]
    pub est_time_enroute: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub sched_time_enroute: u16,
    #[serde(deserialize_with = "ts_from_string")]
    pub sched_out: DateTime<Utc>,
    #[serde(deserialize_with = "ts_from_string")]
    pub sched_off: DateTime<Utc>,
    #[serde(deserialize_with = "ts_from_string")]
    pub sched_on: DateTime<Utc>,
    #[serde(deserialize_with = "ts_from_string")]
    pub sched_in: DateTime<Utc>,
    #[serde(deserialize_with = "u16_from_str")]
    pub sched_block: u16,
    #[serde(deserialize_with = "ts_from_string")]
    pub est_out: DateTime<Utc>,
    #[serde(deserialize_with = "ts_from_string")]
    pub est_off: DateTime<Utc>,
    #[serde(deserialize_with = "ts_from_string")]
    pub est_on: DateTime<Utc>,
    #[serde(deserialize_with = "ts_from_string")]
    pub est_in: DateTime<Utc>,
    #[serde(deserialize_with = "u16_from_str")]
    pub est_block: u16,
    #[serde(deserialize_with = "i8_from_str")]
    pub orig_timezone: i8,
    #[serde(deserialize_with = "i8_from_str")]
    pub dest_timezone: i8,
    #[serde(deserialize_with = "u16_from_str")]
    pub taxi_out: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub taxi_in: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub reserve_time: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub endurance: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub contfuel_time: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub etopsfuel_time: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub extrafuel_time: u16,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Weights {
    #[serde(deserialize_with = "u32_from_str")]
    pub oew: u32,
    #[serde(deserialize_with = "u16_from_str")]
    pub pax_count: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub bag_count: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub pax_count_actual: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub bag_count_actual: u16,
    #[serde(deserialize_with = "f64_from_str")]
    pub pax_weight: f64,
    #[serde(deserialize_with = "f64_from_str")]
    pub bag_weight: f64,
    #[serde(deserialize_with = "f64_from_str")]
    pub freight_added: f64,
    #[serde(deserialize_with = "u32_from_str")]
    pub cargo: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub payload: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub est_zfw: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub max_zfw: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub est_tow: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub max_tow: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub max_tow_struct: u32,
    pub tow_limit_code: String,
    #[serde(deserialize_with = "u32_from_str")]
    pub est_ldw: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub max_ldw: u32,
    #[serde(deserialize_with = "u32_from_str")]
    pub est_ramp: u32,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Impacts {
    pub minus_6000ft: Option<Impact>,
    pub minus_4000ft: Option<Impact>,
    pub minus_2000ft: Option<Impact>,
    pub plus_2000ft: Option<Impact>,
    pub plus_4000ft: Option<Impact>,
    pub plus_6000ft: Option<Impact>,
    pub higher_ci: Option<Impact>,
    pub lower_ci: Option<Impact>,
    pub zfw_plus_1000: Option<Impact>,
    pub zfw_minus_1000: Option<Impact>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Impact {
    #[serde(deserialize_with = "u32_from_str")]
    pub time_enroute: u32,
    #[serde(deserialize_with = "i32_from_str")]
    pub time_difference: i32,
    #[serde(deserialize_with = "u32_from_str")]
    pub enroute_burn: u32,
    #[serde(deserialize_with = "i32_from_str")]
    pub burn_difference: i32,
    #[serde(deserialize_with = "u32_from_str")]
    pub ramp_fuel: u32,
    #[serde(deserialize_with = "u16_from_str")]
    pub initial_fl: u16,
    #[serde(deserialize_with = "u16_from_str")]
    pub initial_tas: u16,
    pub initial_mach: String,
    #[serde(deserialize_with = "u16_from_str")]
    pub cost_index: u16,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Crew {
    #[serde(deserialize_with = "u32_from_str")]
    pub pilot_id: u32,
    pub cpt: String,
    pub fo: String,
    pub dx: String,
    pub pu: String,
    pub fa: Vec<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Notams {
    #[serde(alias = "rec-count")]
    pub rec_count: String,
    pub notamdrec: Vec<NotamDrec>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct NotamDrec {
    pub source_id: String,
    pub account_id: String,
    #[serde(alias = "notam_id")]
    pub id: String,
    #[serde(alias = "notam_part")]
    pub part: String,
    pub cns_location_id: String,
    pub icao_id: String,
    pub icao_name: Option<String>,
    pub total_parts: String,
    #[serde(alias = "notam_created_dtg")]
    pub created_dtg: String,
    #[serde(alias = "notam_effective_dtg")]
    pub effective_dtg: String,
    #[serde(alias = "notam_expire_dtg")]
    pub expire_dtg: Option<String>,
    #[serde(alias = "notam_expire_dtg_estimated")]
    pub expire_dtg_estimated: Option<String>,
    #[serde(alias = "notam_lastmod_dtg")]
    pub lastmod_dtg: String,
    #[serde(alias = "notam_inserted_dtg")]
    pub inserted_dtg: String,
    #[serde(alias = "notam_text")]
    pub text: String,
    #[serde(alias = "notam_report")]
    pub report: String,
    #[serde(alias = "notam_nrc")]
    pub nrc: Option<String>,
    #[serde(alias = "notam_qcode")]
    pub qcode: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Weather {
    pub orig_metar: String,
    pub orig_taf: String,
    pub dest_metar: String,
    pub dest_taf: String,
    pub altn_metar: Option<Vec<String>>,
    pub altn_taf: Option<Vec<String>>,
    pub toaltn_metar: Option<String>,
    pub toaltn_taf: Option<String>,
    pub eualtn_metar: Option<String>,
    pub eualtn_taf: Option<String>,
    pub etops_metar: Option<Vec<String>>,
    pub etops_taf: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Sigmets {
    pub sigmet: Vec<Sigmet>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Sigmet {
    #[serde(alias = "type")]
    pub variant: String,
    pub loc: String,
    pub address: String,
    pub title: String,
    pub fir: String,
    pub fir_name: String,
    pub id: String,
    pub hazard: String,
    pub qualifier: Option<String>,
    #[serde(deserialize_with = "ts_from_string")]
    pub issued: DateTime<Utc>,
    #[serde(deserialize_with = "ts_from_string")]
    pub start: DateTime<Utc>,
    #[serde(deserialize_with = "ts_from_string")]
    pub end: DateTime<Utc>,
    pub text: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GenericOfp {
    pub user_id: u32,
    pub time: u32,
    pub airac: String,
    pub airline_icao: String,
    pub flight_number: String,
    pub callsign: String,
    pub costindex: u16,
    pub initial_altitude: u16,
    pub stepclimb: String,
    pub route_distance: u16,
    pub total_burn: u32,
    pub route: String,
    pub origin_icao: String,
    pub origin_name: String,
    pub origin_plan_rwy: String,
    pub origin_procedure: String,
    pub destination_icao: String,
    pub destination_name: String,
    pub destination_plan_rwy: String,
    pub destination_procedure: String,
    pub alternates: Vec<String>,
}