gistools/readers/gbfs/schema_v3/
gbfs.rs

1use alloc::{string::String, vec::Vec};
2use serde::{Deserialize, Serialize};
3
4/// # GBFS Schema V3.1-RC OR GBFS Schema V3.0
5/// Auto-discovery file that links to all of the other files published by the system.
6///
7/// ## Links
8/// - [GBFS Specification V3.1-RC](https://github.com/MobilityData/gbfs/blob/v3.1-RC/gbfs.md#gbfsjson)
9/// - [GBFS Specification V3.0](https://github.com/MobilityData/gbfs/blob/v3.0/gbfs.md#gbfsjson)
10pub type GBFSV3 = GBFSV30;
11
12/// GBFS Schema V3.0 Feeds Names
13#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
14pub enum GBFSV30FeedsName {
15    /// GBFS
16    #[default]
17    #[serde(rename = "gbfs")]
18    Gbfs,
19    /// GBFS Versions
20    #[serde(rename = "gbfs_versions")]
21    GbfsVersions,
22    /// System Information
23    #[serde(rename = "system_information")]
24    SystemInformation,
25    /// Vehicle Types
26    #[serde(rename = "vehicle_types")]
27    VehicleTypes,
28    /// Station Information
29    #[serde(rename = "station_information")]
30    StationInformation,
31    /// Station Status
32    #[serde(rename = "station_status")]
33    StationStatus,
34    /// Vehicle Status
35    #[serde(rename = "vehicle_status")]
36    VehicleStatus,
37    /// System Alerts
38    #[serde(rename = "system_alerts")]
39    SystemAlerts,
40    /// System Regions
41    #[serde(rename = "system_regions")]
42    SystemRegions,
43    /// System Pricing Plans
44    #[serde(rename = "system_pricing_plans")]
45    SystemPricingPlans,
46    /// Geofencing Zones
47    #[serde(rename = "geofencing_zones")]
48    GeofencingZones,
49}
50
51/// GBFS V3.0 Data Schema
52#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
53pub struct GBFSV30Feed {
54    /// 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.
55    /// **Enum**: ['gbfs', 'gbfs_versions', 'system_information', 'vehicle_types', 'station_information', 'station_status', 'vehicle_status', 'system_alerts', 'system_regions', 'system_pricing_plans', 'geofencing_zones']
56    pub name: GBFSV30FeedsName,
57    /// URL to the feed file.
58    /// **Format**: url
59    pub url: String,
60}
61
62/// GBFS V3.0 Data Schema
63#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
64pub struct GBFSDataV30 {
65    /// An array of all of the feeds that are published by the auto-discovery file.
66    pub feeds: Vec<GBFSV30Feed>,
67}
68
69/// # GBFS Schema V3.0
70/// Auto-discovery file that links to all of the other files published by the system.
71///
72/// ## Links
73/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v3.0/gbfs.md#gbfsjson)
74#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
75pub struct GBFSV30 {
76    /// Last time the data in the feed was updated in RFC3339 format.
77    /// **Format**: date-time
78    pub last_updated: String,
79    /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
80    /// **Minimum**: 0
81    pub ttl: u64,
82    /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
83    /// **Const**: 3.0
84    pub version: String,
85    /// Contains the data for feeds published by the auto-discovery file.
86    pub data: GBFSDataV30,
87}