gistools/readers/gbfs/schema_v2/gbfs.rs
1use alloc::{collections::BTreeMap, string::String, vec::Vec};
2use serde::{Deserialize, Serialize};
3
4/// # GBFS Auto-Discovery Schema V2.x
5/// Auto-discovery file that links to all of the other files published by the system.
6///
7/// ## Links
8/// - [GBFS Specification V2.3](https://github.com/MobilityData/gbfs/blob/v2.3/gbfs.md#gbfsjson)
9/// - [GBFS Specification V2.2](https://github.com/MobilityData/gbfs/blob/v2.2/gbfs.md#gbfsjson)
10/// - [GBFS Specification V2.1](https://github.com/MobilityData/gbfs/blob/v2.1/gbfs.md#gbfsjson)
11/// - [GBFS Specification V2.0](https://github.com/MobilityData/gbfs/blob/v2.0/gbfs.md#gbfsjson)
12pub type GBFSV2 = GBFSV23;
13
14/// # GBFS V2.3 Feed Schema
15#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
16pub struct GBFSV23Feed {
17 /// Key identifying the type of feed this is. The key must be the base file name defined in the spec for the corresponding feed type.
18 ///
19 /// **Enum**: "gbfs", "gbfs_versions", "system_information", "vehicle_types", "station_information", "station_status", "free_bike_status", "system_hours", "system_alerts", "system_calendar", "system_regions", "system_pricing_plans", "geofencing_zones"
20 pub name: GBFSV21FeedsName,
21 /// URL for the feed.
22 /// **Format**: uri
23 pub url: String,
24}
25
26/// # GBFS V2.3 Data Schema
27#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
28pub struct GBFSDataV23 {
29 /// An array of all of the feeds that are published by the auto-discovery file.
30 pub feeds: Vec<GBFSV23Feed>,
31}
32
33/// # GBFS Auto-Discovery V2.3
34/// Auto-discovery file that links to all of the other files published by the system.
35///
36/// ## Links
37/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.3/gbfs.md#gbfsjson)
38#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
39pub struct GBFSV23 {
40 /// Last time the data in the feed was updated in POSIX time.
41 /// **Minimum**: 1450155600
42 pub last_updated: u64,
43 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
44 /// **Minimum**: 0
45 pub ttl: u64,
46 /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
47 /// **Const**: 2.3
48 pub version: String,
49 /// Response data in the form of name:value pairs.
50 pub data: BTreeMap<String, GBFSDataV23>,
51}
52
53/// # GBFS Feed Schema V2.2
54#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
55pub struct GBFSV22Feed {
56 /// Key identifying the type of feed this is. The key must be the base file name defined in the spec for the corresponding feed type.
57 ///
58 /// **Enum**: "gbfs", "gbfs_versions", "system_information", "vehicle_types", "station_information", "station_status", "free_bike_status", "system_hours", "system_alerts", "system_calendar", "system_regions", "system_pricing_plans", "geofencing_zones"
59 pub name: GBFSV21FeedsName,
60 /// URL for the feed.
61 /// **Format**: uri
62 pub url: String,
63}
64
65/// # GBFS Data Schema V2.2
66#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
67pub struct GBFSDataV22 {
68 /// An array of all of the feeds that are published by the auto-discovery file.
69 pub feeds: Vec<GBFSV22Feed>,
70}
71
72/// # GBFS Auto-Discovery V2.2
73/// Auto-discovery file that links to all of the other files published by the system.
74///
75/// ## Links
76/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.2/gbfs.md#gbfsjson)
77#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
78pub struct GBFSV22 {
79 /// Last time the data in the feed was updated in POSIX time.
80 /// **Minimum**: 1450155600
81 pub last_updated: u64,
82 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
83 /// **Minimum**: 0
84 pub ttl: u64,
85 /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
86 /// **Const**: 2.2
87 pub version: String,
88 /// Response data in the form of name:value pairs.
89 pub data: BTreeMap<String, GBFSDataV22>,
90}
91
92/// GBFS Schema V2.1 Feeds Names
93#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
94pub enum GBFSV21FeedsName {
95 /// GBFS
96 #[default]
97 #[serde(rename = "gbfs")]
98 Gbfs,
99 /// GBFS Versions
100 #[serde(rename = "gbfs_versions")]
101 GbfsVersions,
102 /// System Information
103 #[serde(rename = "system_information")]
104 SystemInformation,
105 /// Vehicle Types
106 #[serde(rename = "vehicle_types")]
107 VehicleTypes,
108 /// Station Information
109 #[serde(rename = "station_information")]
110 StationInformation,
111 /// Station Status
112 #[serde(rename = "station_status")]
113 StationStatus,
114 /// Free Bike Status
115 #[serde(rename = "free_bike_status")]
116 FreeBikeStatus,
117 /// System Hours
118 #[serde(rename = "system_hours")]
119 SystemHours,
120 /// System Alerts
121 #[serde(rename = "system_alerts")]
122 SystemAlerts,
123 /// System Calendar
124 #[serde(rename = "system_calendar")]
125 SystemCalendar,
126 /// System Regions
127 #[serde(rename = "system_regions")]
128 SystemRegions,
129 /// System Pricing Plans
130 #[serde(rename = "system_pricing_plans")]
131 SystemPricingPlans,
132 /// Geofencing Zones
133 #[serde(rename = "geofencing_zones")]
134 GeofencingZones,
135}
136
137/// # GBFS Feed Schema V2.1
138#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
139pub struct GBFSV21Feed {
140 /// Key identifying the type of feed this is. The key must be the base file name defined in the spec for the corresponding feed type.
141 ///
142 /// **Enum**: "gbfs", "gbfs_versions", "system_information", "vehicle_types", "station_information", "station_status", "free_bike_status", "system_hours", "system_alerts", "system_calendar", "system_regions", "system_pricing_plans", "geofencing_zones"
143 pub name: GBFSV21FeedsName,
144 /// URL for the feed.
145 /// **Format**: uri
146 pub url: String,
147}
148
149/// # GBFS Data Schema V2.1
150#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
151pub struct GBFSDataV21 {
152 /// An array of all of the feeds that are published by the auto-discovery file.
153 pub feeds: Vec<GBFSV21Feed>,
154}
155
156/// # GBFS V2.1
157/// Auto-discovery file that links to all of the other files published by the system.
158///
159/// ## Links
160/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.1/gbfs.md#gbfsjson)
161#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
162pub struct GBFSV21 {
163 /// Last time the data in the feed was updated in POSIX time.
164 /// **Minimum**: 1450155600
165 pub last_updated: u64,
166 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
167 /// **Minimum**: 0
168 pub ttl: u64,
169 /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
170 /// **Const**: 2.1
171 pub version: String,
172 /// Response data in the form of name:value pairs.
173 pub data: BTreeMap<String, GBFSDataV21>,
174}
175
176/// GBFS Schema V2.0 Feeds Names
177#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
178pub enum GBFSV20FeedsName {
179 /// GBFS
180 #[default]
181 #[serde(rename = "gbfs")]
182 Gbfs,
183 /// GBFS Versions
184 #[serde(rename = "gbfs_versions")]
185 GbfsVersions,
186 /// System Information
187 #[serde(rename = "system_information")]
188 SystemInformation,
189 /// Station Information
190 #[serde(rename = "station_information")]
191 StationInformation,
192 /// Station Status
193 #[serde(rename = "station_status")]
194 StationStatus,
195 /// Free Bike Status
196 #[serde(rename = "free_bike_status")]
197 FreeBikeStatus,
198 /// System Hours
199 #[serde(rename = "system_hours")]
200 SystemHours,
201 /// System Alerts
202 #[serde(rename = "system_alerts")]
203 SystemAlerts,
204 /// System Calendar
205 #[serde(rename = "system_calendar")]
206 SystemCalendar,
207 /// System Regions
208 #[serde(rename = "system_regions")]
209 SystemRegions,
210 /// System Pricing Plans
211 #[serde(rename = "system_pricing_plans")]
212 SystemPricingPlans,
213}
214
215/// GBFS V2.0 Feed Schema
216#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
217pub struct GBFSV20Feed {
218 /// Key identifying the type of feed this is. The key must be the base file name defined in the spec for the corresponding feed type.
219 ///
220 /// **Enum**: "gbfs", "gbfs_versions", "system_information", "station_information", "station_status", "free_bike_status", "system_hours", "system_alerts", "system_calendar", "system_regions", "system_pricing_plans"
221 pub name: GBFSV20FeedsName,
222 /// URL for the feed.
223 /// **Format**: uri
224 pub url: String,
225}
226
227/// GBFS V2.0 Data Schema
228#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
229pub struct GBFSDataV20 {
230 /// An array of all of the feeds that are published by the auto-discovery file.
231 pub feeds: Vec<GBFSV20Feed>,
232}
233
234/// # GBFS V2.0
235/// Auto-discovery file that links to all of the other files published by the system.
236///
237/// ## Links
238/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.0/gbfs.md#gbfsjson)
239#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
240pub struct GBFSV20 {
241 /// Last time the data in the feed was updated in POSIX time.
242 /// **Minimum**: 1450155600
243 pub last_updated: u64,
244 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
245 /// **Minimum**: 0
246 pub ttl: u64,
247 /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
248 /// **Const**: 2.0
249 pub version: String,
250 /// Response data in the form of name:value pairs.
251 /// An object containing feeds keyed by language code (e.g., "en", "en-US").
252 ///
253 /// **Pattern**: `^[a-z]{2,3}(-[A-Z]{2})?$`
254 pub data: BTreeMap<String, GBFSDataV20>,
255}