italo_api/train/
mod.rs

1use getset::Getters;
2use serde::Deserialize;
3
4/// Realtime data for a train
5#[derive(Deserialize, Debug, Getters)]
6#[serde(rename_all = "PascalCase")]
7#[get = "pub"]
8pub struct TrainRealtime {
9    last_update: String,
10    train_schedule: TrainSchedule,
11}
12
13/// Train trip
14#[derive(Deserialize, Debug, Getters)]
15#[get = "pub"]
16#[serde(rename_all = "PascalCase")]
17pub struct TrainSchedule {
18    /// Italo ID
19    train_number: String,
20
21    /// Rete Ferroviaria Italian ID
22    rfi_train_number: String,
23
24    /// Scheduled departure time
25    #[serde(rename(deserialize = "DepartureDate"))]
26    departure_time: String,
27
28    ///First trip station name
29    #[serde(rename(deserialize = "DepartureStationDescription"))]
30    departure_station_name: String,
31
32    /// Scheduled arrival time
33    #[serde(rename(deserialize = "ArrivalDate"))]
34    arrival_time: String,
35
36    /// Terminus station
37    #[serde(rename(deserialize = "ArrivalStationDescription"))]
38    arrival_station_name: String,
39
40    /// Service disruption data
41    #[serde(rename(deserialize = "Distruption"))]
42    disruption: Disruption,
43
44    /// Additional information on the first station
45    #[serde(rename(deserialize = "StazionePartenza"))]
46    departure_station: TrainStation,
47
48    /// Stations where the train has already stopped
49    #[serde(rename(deserialize = "StazioniFerme"))]
50    stations_with_stop: Vec<TrainStation>,
51
52    /// Stations where it will stop
53    #[serde(rename(deserialize = "StazioniNonFerme"))]
54    stations_with_transit: Vec<TrainStation>,
55}
56
57/// Disruption data
58#[derive(Deserialize, Debug, Getters)]
59#[serde(rename_all = "PascalCase")]
60#[get = "pub"]
61pub struct Disruption {
62    /// Delay (in minutes)
63    delay_amount: i32,
64
65    /// Unknown
66    location_code: String,
67
68    /// Unknown
69    warning: bool,
70
71    /// Unknown
72    running_state: u16,
73}
74
75/// Station data enriched with train information
76#[derive(Deserialize, Debug, Getters)]
77#[serde(rename_all = "PascalCase")]
78#[get = "pub"]
79pub struct TrainStation {
80    /// Italo station ID
81    location_code: String,
82
83    /// Human firendly name
84    location_description: String,
85
86    /// Rete Ferroviaria Italiana ID
87    rfi_location_code: String,
88
89    /// Estimated time by which the train will leave the station
90    estimated_departure_time: String,
91
92    /// Real time by which the train will leave the station
93    actual_departure_time: String,
94
95    /// Estimated time by which the train will arrive to the station
96    estimated_arrival_time: String,
97
98    /// Real time by which the train will arrive to the station
99    actual_arrival_time: String,
100
101    /// Platform
102    #[serde(rename(deserialize = "ActualArrivalPlatform"))]
103    platform: Option<String>,
104
105    /// Station index in the trip plan
106    #[serde(rename(deserialize = "StationNumber"))]
107    sequence: u8,
108}