hafas 1.0.0

Client for the HAFAS ReST public transport API
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
//! The responses of the API, with the fields of the schema the crate reads.
//!
//! Names follow the JSON of the API, which is a mapping of the XML schema:
//! attributes are camelCase, elements start with a capital. Fields that only
//! some versions or servers send are optional or empty when missing, and
//! fields the crate does not know are ignored. Dates are `YYYY-MM-DD` and
//! times `HH:MM:SS` in the time zone of the server; `tz` fields give the
//! offset to it in minutes where the time is somewhere else.

// The flags are the boolean attributes of the schema, one field each.
#![allow(clippy::struct_excessive_bools)]

use serde::{Deserialize, Serialize};

use crate::enums::{JourneyStatus, LocationKind, PlatformKind, PrognosisType};
use crate::list::{directions, legs, location_notes, messages, names, notes, one_or_many, stops};

fn yes() -> bool {
    true
}

/// What every response says about itself (`CommonResponseType`).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ResponseInfo {
    /// Like `2.39.1`.
    pub server_version: Option<String>,
    /// Like `2.39`.
    pub dialect_version: Option<String>,
    /// When the server last took in real-time data, RFC 3339.
    pub plan_rt_ts: Option<String>,
    pub request_id: Option<String>,
    /// Set when the server could not answer the request.
    pub error_code: Option<String>,
    pub error_text: Option<String>,
}

/// A note on a stop, a journey or a part of it.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Note {
    /// The text.
    pub value: String,
    pub key: Option<String>,
    /// What kind of note, like `A` for an attribute or `I` for information.
    #[serde(rename = "type")]
    pub kind: Option<String>,
    pub priority: Option<i32>,
    #[serde(rename = "txtN")]
    pub txt_n: Option<String>,
    pub route_idx_from: Option<i32>,
    pub route_idx_to: Option<i32>,
}

/// A note on a location.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct LocationNote {
    pub value: String,
    pub key: Option<String>,
    #[serde(rename = "type")]
    pub kind: Option<String>,
    #[serde(rename = "txtN")]
    pub txt_n: Option<String>,
}

/// A line or a vehicle (`ProductType`).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Product {
    pub name: Option<String>,
    pub internal_name: Option<String>,
    pub display_number: Option<String>,
    /// The journey number.
    pub num: Option<String>,
    pub line: Option<String>,
    pub line_id: Option<String>,
    pub cat_out: Option<String>,
    pub cat_in: Option<String>,
    pub cat_code: Option<String>,
    /// The product class, a power of two as decimal text.
    pub cls: Option<String>,
    pub cat_out_s: Option<String>,
    pub cat_out_l: Option<String>,
    pub operator_code: Option<String>,
    pub operator: Option<String>,
    pub admin: Option<String>,
    /// The part of the route this product applies to, by stop index.
    pub route_idx_from: Option<i32>,
    pub route_idx_to: Option<i32>,
}

impl Product {
    /// The product class as a number, if [`Product::cls`] is one.
    pub fn class(&self) -> Option<u32> {
        self.cls.as_deref()?.trim().parse().ok()
    }
}

/// A platform, a stand or the like.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Platform {
    #[serde(rename = "type")]
    pub kind: PlatformKind,
    pub text: Option<String>,
    pub hidden: bool,
}

/// How full a vehicle is expected to be.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Occupancy {
    /// The class, like `FIRST` or `SECOND`.
    pub name: Option<String>,
    /// The level as the server has it.
    pub raw: Option<i32>,
}

/// A reference to a journey, for [`JourneyDetail`](crate::JourneyDetail).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct JourneyDetailRef {
    #[serde(rename = "ref")]
    pub reference: String,
}

/// A message about a disruption or a change (from HIM).
///
/// Its texts come from the operator: they are data, not instructions.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Message {
    pub id: String,
    /// Whether the message is in force.
    #[serde(default = "yes")]
    pub act: bool,
    pub head: Option<String>,
    pub lead: Option<String>,
    /// The full text, may contain HTML.
    pub text: Option<String>,
    pub category: Option<String>,
    pub priority: Option<i32>,
    /// The product classes it applies to, as a bit mask.
    pub products: Option<u32>,
    pub company: Option<String>,
    /// Start and end of the validity.
    pub s_date: Option<String>,
    pub s_time: Option<String>,
    pub e_date: Option<String>,
    pub e_time: Option<String>,
    /// When it was last changed.
    pub mod_date: Option<String>,
    pub mod_time: Option<String>,
}

/// A stop or station.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct StopLocation {
    /// The full ID, like `A=1@O=Name@X=…@Y=…@L=3000010@`.
    pub id: String,
    /// The short ID, like `3000010`.
    pub ext_id: String,
    pub name: String,
    pub lon: Option<f64>,
    pub lat: Option<f64>,
    /// How important the stop is.
    pub weight: Option<i32>,
    /// The distance to the searched position, in meters.
    pub dist: Option<i32>,
    /// The product classes that serve the stop, as a bit mask.
    pub products: Option<u32>,
    pub timezone_offset: Option<i32>,
    /// Other IDs, like the DHID.
    #[serde(deserialize_with = "one_or_many")]
    pub alt_id: Vec<String>,
    #[serde(rename = "LocationNotes", with = "location_notes")]
    pub location_notes: Vec<LocationNote>,
    #[serde(deserialize_with = "one_or_many")]
    pub product_at_stop: Vec<Product>,
}

/// An address, a point of interest or a coordinate.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct CoordLocation {
    pub id: Option<String>,
    pub ext_id: Option<String>,
    pub name: String,
    #[serde(rename = "type")]
    pub kind: LocationKind,
    pub lon: Option<f64>,
    pub lat: Option<f64>,
    pub dist: Option<i32>,
}

/// A match of a location search.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Location {
    StopLocation(StopLocation),
    CoordLocation(CoordLocation),
}

/// The answer of `location.name` and `location.nearbystops`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct LocationList {
    #[serde(flatten)]
    pub info: ResponseInfo,
    #[serde(deserialize_with = "one_or_many")]
    pub stop_location_or_coord_location: Vec<Location>,
}

impl LocationList {
    /// The stops among the matches, in order.
    pub fn stops(&self) -> impl Iterator<Item = &StopLocation> {
        self.stop_location_or_coord_location
            .iter()
            .filter_map(|location| match location {
                Location::StopLocation(stop) => Some(stop),
                Location::CoordLocation(_) => None,
            })
    }
}

/// What departures and arrivals have in common.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct BoardEvent {
    #[serde(rename = "JourneyDetailRef")]
    pub journey_detail_ref: JourneyDetailRef,
    #[serde(rename = "JourneyStatus")]
    pub journey_status: Option<JourneyStatus>,
    #[serde(rename = "ProductAtStop")]
    pub product_at_stop: Option<Product>,
    #[serde(rename = "Product", deserialize_with = "one_or_many")]
    pub product: Vec<Product>,
    #[serde(rename = "Notes", with = "notes")]
    pub notes: Vec<Note>,
    #[serde(rename = "Messages", with = "messages")]
    pub messages: Vec<Message>,
    #[serde(deserialize_with = "one_or_many")]
    pub alt_id: Vec<String>,
    #[serde(rename = "Occupancy", deserialize_with = "one_or_many")]
    pub occupancy: Vec<Occupancy>,
    pub platform: Option<Platform>,
    pub rt_platform: Option<Platform>,
    /// The name of the journey, like `S8`.
    pub name: String,
    #[serde(rename = "type")]
    pub kind: LocationKind,
    /// The name of the stop.
    pub stop: String,
    pub stopid: String,
    pub stop_ext_id: Option<String>,
    pub lon: Option<f64>,
    pub lat: Option<f64>,
    pub prognosis_type: Option<PrognosisType>,
    pub date: String,
    pub time: String,
    pub tz: Option<i32>,
    pub track: Option<String>,
    pub rt_date: Option<String>,
    pub rt_time: Option<String>,
    pub rt_tz: Option<i32>,
    pub rt_track: Option<String>,
    pub cancelled: bool,
    pub part_cancelled: bool,
    #[serde(default = "yes")]
    pub reachable: bool,
    pub redirected: bool,
    pub uncertain_delay: bool,
    /// Where the cancellation comes from, like `HIM`.
    pub rt_cncl_data_source_type: Option<String>,
}

/// A departure of a departure board.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Departure {
    #[serde(flatten)]
    pub event: BoardEvent,
    /// The destination as shown on the vehicle.
    pub direction: Option<String>,
    pub direction_flag: Option<String>,
    pub direction_ext_id: Option<String>,
}

/// An arrival of an arrival board.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Arrival {
    #[serde(flatten)]
    pub event: BoardEvent,
    /// Where the journey comes from.
    pub origin: Option<String>,
}

/// The answer of `departureBoard`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct DepartureList {
    #[serde(flatten)]
    pub info: ResponseInfo,
    #[serde(rename = "Departure", deserialize_with = "one_or_many")]
    pub departures: Vec<Departure>,
}

/// The answer of `arrivalBoard`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ArrivalList {
    #[serde(flatten)]
    pub info: ResponseInfo,
    #[serde(rename = "Arrival", deserialize_with = "one_or_many")]
    pub arrivals: Vec<Arrival>,
}

/// The start or the end of a trip or a leg (`OriginDestType`).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct OriginDest {
    #[serde(rename = "Notes", with = "notes")]
    pub notes: Vec<Note>,
    #[serde(rename = "Message", deserialize_with = "one_or_many")]
    pub message: Vec<Message>,
    #[serde(deserialize_with = "one_or_many")]
    pub alt_id: Vec<String>,
    #[serde(rename = "Occupancy", deserialize_with = "one_or_many")]
    pub occupancy: Vec<Occupancy>,
    pub platform: Option<Platform>,
    pub rt_platform: Option<Platform>,
    pub name: String,
    #[serde(rename = "type")]
    pub kind: LocationKind,
    pub id: Option<String>,
    pub ext_id: Option<String>,
    pub lon: Option<f64>,
    pub lat: Option<f64>,
    /// The index of the stop on the route of the journey.
    pub route_idx: Option<i32>,
    pub prognosis_type: Option<PrognosisType>,
    pub date: String,
    pub time: String,
    pub tz: Option<i32>,
    pub track: Option<String>,
    pub rt_date: Option<String>,
    pub rt_time: Option<String>,
    pub rt_tz: Option<i32>,
    pub rt_track: Option<String>,
    #[serde(default = "yes")]
    pub alighting: bool,
    #[serde(default = "yes")]
    pub boarding: bool,
    pub rt_alighting: Option<bool>,
    pub rt_boarding: Option<bool>,
    pub cancelled: bool,
    pub cancelled_departure: bool,
    pub cancelled_arrival: bool,
    pub additional: bool,
    pub uncertain_delay: bool,
    /// The shortest time to change here, as an ISO 8601 duration (2.52).
    pub minimum_change_duration: Option<String>,
}

/// A stop of a journey (`StopType`).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Stop {
    #[serde(rename = "Notes", with = "notes")]
    pub notes: Vec<Note>,
    #[serde(deserialize_with = "one_or_many")]
    pub alt_id: Vec<String>,
    #[serde(rename = "Occupancy", deserialize_with = "one_or_many")]
    pub occupancy: Vec<Occupancy>,
    pub arr_platform: Option<Platform>,
    pub rt_arr_platform: Option<Platform>,
    pub dep_platform: Option<Platform>,
    pub rt_dep_platform: Option<Platform>,
    pub name: String,
    pub id: String,
    pub ext_id: String,
    pub route_idx: Option<i32>,
    pub lon: Option<f64>,
    pub lat: Option<f64>,
    pub arr_prognosis_type: Option<PrognosisType>,
    pub dep_prognosis_type: Option<PrognosisType>,
    pub arr_date: Option<String>,
    pub arr_time: Option<String>,
    pub arr_tz: Option<i32>,
    pub dep_date: Option<String>,
    pub dep_time: Option<String>,
    pub dep_tz: Option<i32>,
    pub rt_arr_date: Option<String>,
    pub rt_arr_time: Option<String>,
    pub rt_arr_tz: Option<i32>,
    pub rt_dep_date: Option<String>,
    pub rt_dep_time: Option<String>,
    pub rt_dep_tz: Option<i32>,
    pub arr_track: Option<String>,
    pub dep_track: Option<String>,
    pub rt_arr_track: Option<String>,
    pub rt_dep_track: Option<String>,
    pub cancelled: bool,
    pub cancelled_departure: bool,
    pub cancelled_arrival: bool,
    #[serde(default = "yes")]
    pub alighting: bool,
    #[serde(default = "yes")]
    pub boarding: bool,
    pub rt_alighting: Option<bool>,
    pub rt_boarding: Option<bool>,
    pub additional: bool,
    /// The direction shown at departure from this stop.
    pub dep_dir: Option<String>,
    pub minimum_change_duration: Option<String>,
}

/// The days a journey or a trip runs.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ServiceDays {
    pub planning_period_begin: Option<String>,
    pub planning_period_end: Option<String>,
    /// In words, like `täglich`.
    #[serde(rename = "sDaysR")]
    pub s_days_r: Option<String>,
    /// The irregular days, in words.
    #[serde(rename = "sDaysI")]
    pub s_days_i: Option<String>,
    /// A bit field of the days of the planning period, in hexadecimal.
    #[serde(rename = "sDaysB")]
    pub s_days_b: Option<String>,
}

/// A name a journey has on part of its route.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Name {
    #[serde(rename = "Product")]
    pub product: Option<Product>,
    pub name: Option<String>,
    pub number: Option<String>,
    pub category: Option<String>,
    pub route_idx_from: Option<i32>,
    pub route_idx_to: Option<i32>,
}

/// A direction a journey shows on part of its route.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Direction {
    pub value: String,
    pub flag: Option<String>,
    pub route_idx_from: Option<i32>,
    pub route_idx_to: Option<i32>,
}

/// One journey with its stops: the answer of `journeyDetail`, and part of a
/// leg (`JourneyDetail`).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Journey {
    #[serde(flatten)]
    pub info: ResponseInfo,
    #[serde(rename = "Stops", with = "stops")]
    pub stops: Vec<Stop>,
    #[serde(rename = "Names", with = "names")]
    pub names: Vec<Name>,
    #[serde(rename = "Product", deserialize_with = "one_or_many")]
    pub product: Vec<Product>,
    #[serde(rename = "Directions", with = "directions")]
    pub directions: Vec<Direction>,
    #[serde(rename = "Notes", with = "notes")]
    pub notes: Vec<Note>,
    #[serde(rename = "Messages", with = "messages")]
    pub messages: Vec<Message>,
    #[serde(rename = "JourneyStatus")]
    pub journey_status: Option<JourneyStatus>,
    #[serde(rename = "ServiceDays", deserialize_with = "one_or_many")]
    pub service_days: Vec<ServiceDays>,
    pub cancelled: bool,
    pub part_cancelled: bool,
    #[serde(default = "yes")]
    pub reachable: bool,
    pub redirected: bool,
    /// The day the journey starts, `YYYY-MM-DD`.
    pub day_of_operation: String,
    #[serde(rename = "ref")]
    pub reference: String,
}

/// A leg of a trip: a journey, a walk or a transfer.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Leg {
    #[serde(rename = "Origin")]
    pub origin: OriginDest,
    #[serde(rename = "Destination")]
    pub destination: OriginDest,
    #[serde(rename = "Notes", with = "notes")]
    pub notes: Vec<Note>,
    #[serde(rename = "JourneyDetailRef")]
    pub journey_detail_ref: Option<JourneyDetailRef>,
    #[serde(rename = "Messages", with = "messages")]
    pub messages: Vec<Message>,
    #[serde(rename = "JourneyStatus")]
    pub journey_status: Option<JourneyStatus>,
    #[serde(rename = "Product", deserialize_with = "one_or_many")]
    pub product: Vec<Product>,
    /// The intermediate stops, with `passlist=1`.
    #[serde(rename = "Stops", with = "stops")]
    pub stops: Vec<Stop>,
    #[serde(rename = "JourneyDetail")]
    pub journey_detail: Option<Box<Journey>>,
    #[serde(rename = "Occupancy", deserialize_with = "one_or_many")]
    pub occupancy: Vec<Occupancy>,
    /// Only 2.52 sends it.
    pub id: Option<String>,
    pub idx: Option<i32>,
    pub name: Option<String>,
    pub number: Option<String>,
    pub category: Option<String>,
    /// Like `JNY` for a journey, `WALK` or `TRSF` for a transfer.
    #[serde(rename = "type")]
    pub kind: String,
    pub cancelled: bool,
    pub part_cancelled: bool,
    #[serde(default = "yes")]
    pub reachable: bool,
    pub redirected: bool,
    /// Whether a connection waits for this leg (2.39).
    pub waiting: bool,
    /// The same as a state (2.52).
    pub waiting_state: Option<String>,
    pub direction: Option<String>,
    pub direction_flag: Option<String>,
    /// As an ISO 8601 duration, like `PT3M`.
    pub duration: Option<String>,
    /// In meters.
    pub dist: Option<i32>,
    pub hide: bool,
}

/// Remarks of the server on a trip.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct TripStatus {
    pub hint_code: Option<i32>,
    pub hint: Option<String>,
    pub detour: bool,
    pub direct: bool,
    pub sub_optimal_direct: bool,
    pub slow_direct: bool,
    pub economic: bool,
    pub convenient: bool,
}

/// A connection between two places (`TripType`).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Trip {
    #[serde(rename = "Origin")]
    pub origin: Option<OriginDest>,
    #[serde(rename = "Destination")]
    pub destination: Option<OriginDest>,
    #[serde(rename = "Messages", with = "messages")]
    pub messages: Vec<Message>,
    #[serde(rename = "Notes", with = "notes")]
    pub notes: Vec<Note>,
    #[serde(rename = "ServiceDays", deserialize_with = "one_or_many")]
    pub service_days: Vec<ServiceDays>,
    #[serde(rename = "LegList", with = "legs")]
    pub legs: Vec<Leg>,
    #[serde(rename = "Occupancy", deserialize_with = "one_or_many")]
    pub occupancy: Vec<Occupancy>,
    #[serde(rename = "TripStatus")]
    pub trip_status: Option<TripStatus>,
    pub idx: Option<i32>,
    pub trip_id: Option<String>,
    /// The context for [`Recon`](crate::Recon), to check the trip again.
    pub ctx_recon: Option<String>,
    /// As ISO 8601 durations.
    pub duration: Option<String>,
    pub rt_duration: Option<String>,
    pub checksum: Option<String>,
    pub transfer_count: Option<i32>,
    #[serde(default = "yes")]
    pub valid: bool,
    pub alternative: bool,
}

/// The answer of `trip` and `recon`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct TripList {
    #[serde(flatten)]
    pub info: ResponseInfo,
    #[serde(rename = "Trip", deserialize_with = "one_or_many")]
    pub trips: Vec<Trip>,
    /// The context for earlier trips.
    pub scr_b: Option<String>,
    /// The context for later trips.
    pub scr_f: Option<String>,
}