gistools/readers/gbfs/schema_v2/system_alerts.rs
1use alloc::{string::String, vec::Vec};
2use serde::{Deserialize, Serialize};
3
4/// # GBFS Alerts Schema V2.3, V2.2, V2.1, OR V2.0
5/// Describes ad-hoc changes to the system.
6///
7/// ## Links
8/// - [GBFS Specification V2.3](https://github.com/MobilityData/gbfs/blob/v2.3/gbfs.md#system_alertsjson)
9/// - [GBFS Specification V2.2](https://github.com/MobilityData/gbfs/blob/v2.2/gbfs.md#system_alertsjson)
10/// - [GBFS Specification V2.1](https://github.com/MobilityData/gbfs/blob/v2.1/gbfs.md#system_alertsjson)
11/// - [GBFS Specification V2.0](https://github.com/MobilityData/gbfs/blob/v2.0/gbfs.md#system_alertsjson)
12pub type GBFSSystemAlertsV2 = GBFSSystemAlertsV23;
13
14/// # GBFS System Alerts V2.3
15/// Describes ad-hoc changes to the system.
16///
17/// ## Links
18/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.3/gbfs.md#system_alertsjson)
19#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
20pub struct GBFSSystemAlertsV23 {
21 /// Last time the data in the feed was updated in POSIX time.
22 /// **Minimum**: 1450155600
23 pub last_updated: u64,
24 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
25 /// **Minimum**: 0
26 pub ttl: u64,
27 /// GBFS version number to which the feed conforms, according to the versioning framework.
28 /// **Const**: 2.3
29 pub version: String,
30 /// Contains system alerts data.
31 pub data: GBFSSystemAlertsDataV21,
32}
33
34/// # GBFS System Alerts V2.2
35/// Describes ad-hoc changes to the system.
36///
37/// ## Links
38/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.2/gbfs.md#system_alertsjson)
39#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
40pub struct GBFSSystemAlertsV22 {
41 /// Last time the data in the feed was updated in POSIX time.
42 /// **Minimum**: 1450155600
43 pub last_updated: u64,
44 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
45 /// **Minimum**: 0
46 pub ttl: u64,
47 /// GBFS version number to which the feed conforms, according to the versioning framework.
48 /// **Const**: 2.2
49 pub version: String,
50 /// Contains system alerts data.
51 pub data: GBFSSystemAlertsDataV21,
52}
53
54/// GBFS System Alerts Alert Type
55#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
56pub enum GBFSSystemAlertsAlertTypeV21 {
57 /// System Closure
58 #[serde(rename = "system_closure")]
59 SystemClosure,
60 /// Station Closure
61 #[serde(rename = "station_closure")]
62 StationClosure,
63 /// Station Move
64 #[serde(rename = "station_move")]
65 StationMove,
66 /// Other
67 #[default]
68 #[serde(rename = "other")]
69 Other,
70}
71
72/// GBFS System Alerts Alert V2.1
73#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
74pub struct GBFSSystemAlertsAlertV21 {
75 /// Unique ID for the alert.
76 pub alert_id: String,
77 /// Type of alert.
78 pub r#type: GBFSSystemAlertsAlertTypeV21,
79 /// Times the alert is in effect.
80 pub times: Option<Vec<GBFSSystemAlertsAlertTimesV20>>,
81 /// IDs of affected stations.
82 pub station_ids: Option<Vec<String>>,
83 /// IDs of affected regions.
84 pub region_ids: Option<Vec<String>>,
85 /// URL to more information about the alert.
86 pub url: Option<String>,
87 /// Summary of the alert.
88 pub summary: String,
89 /// Description of the alert.
90 pub description: Option<String>,
91 /// Last time the alert was updated in POSIX time.
92 pub last_updated: Option<u64>,
93}
94
95/// GBFS System Alerts Data V2.1
96#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
97pub struct GBFSSystemAlertsDataV21 {
98 /// List of system alerts.
99 pub alerts: Vec<GBFSSystemAlertsAlertV21>,
100}
101
102/// # GBFS System Alerts V2.1
103/// Describes ad-hoc changes to the system.
104///
105/// ## Links
106/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.1/gbfs.md#system_alertsjson)
107#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
108pub struct GBFSSystemAlertsV21 {
109 /// Last time the data in the feed was updated in POSIX time.
110 /// **Minimum**: 1450155600
111 pub last_updated: u64,
112 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
113 /// **Minimum**: 0
114 pub ttl: u64,
115 /// GBFS version number to which the feed conforms, according to the versioning framework.
116 /// **Const**: 2.1
117 pub version: String,
118 /// Contains system alerts data.
119 pub data: GBFSSystemAlertsDataV21,
120}
121
122/// GBFS System Alerts Alert Type V2.0
123#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
124pub enum GBFSSystemAlertsAlertTypeV20 {
125 /// System Closure
126 #[serde(rename = "SYSTEM_CLOSURE")]
127 SystemClosure,
128 /// Station Closure
129 #[serde(rename = "STATION_CLOSURE")]
130 StationClosure,
131 /// Station Move
132 #[serde(rename = "STATION_MOVE")]
133 StationMove,
134 /// Other
135 #[default]
136 #[serde(rename = "OTHER")]
137 Other,
138}
139
140/// GBFS System Alerts Alert Times V2.0
141#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
142pub struct GBFSSystemAlertsAlertTimesV20 {
143 /// Start time in POSIX time
144 pub start: u64,
145 /// End time in POSIX time
146 pub end: Option<u64>,
147}
148
149/// GBFS System Alerts Alert V2.0
150#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
151pub struct GBFSSystemAlertsAlertV20 {
152 /// Alert ID
153 pub alert_id: String,
154 /// Alert type
155 pub r#type: GBFSSystemAlertsAlertTypeV20,
156 /// Alert times
157 pub times: Option<Vec<GBFSSystemAlertsAlertTimesV20>>,
158 /// Affected station IDs
159 pub station_ids: Option<Vec<String>>,
160 /// Affected region IDs
161 pub region_ids: Option<Vec<String>>,
162 /// Alert URL
163 pub url: Option<String>,
164 /// Alert summary
165 pub summary: String,
166 /// Alert description
167 pub description: Option<String>,
168 /// Last updated time in POSIX time
169 pub last_updated: Option<u64>,
170}
171
172/// GBFS System Alerts Data V2.0
173#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
174pub struct GBFSSystemAlertsDataV20 {
175 /// Contains system alerts data.
176 pub alerts: Vec<GBFSSystemAlertsAlertV20>,
177}
178
179/// # GBFS System Alerts V2.0
180/// Describes ad-hoc changes to the system.
181///
182/// ## Links
183/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.0/gbfs.md#system_alertsjson)
184#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
185pub struct GBFSSystemAlertsV20 {
186 /// Last time the data in the feed was updated in POSIX time.
187 /// **Minimum**: 1450155600
188 pub last_updated: u64,
189 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
190 /// **Minimum**: 0
191 pub ttl: u64,
192 /// GBFS version number to which the feed conforms, according to the versioning framework.
193 /// **Const**: 2.0
194 pub version: String,
195 /// Contains system alerts data.
196 pub data: GBFSSystemAlertsDataV20,
197}