gistools/readers/gbfs/schema_v1/
gbfs.rs

1use alloc::{collections::BTreeMap, string::String, vec::Vec};
2use serde::{Deserialize, Serialize};
3
4/// # GBFS Schema V1.1 OR GBFS Schema V1.0
5/// Auto-discovery file that links to all of the other files published by the system.
6///
7/// ## Links
8/// - [GBFS Specification V1.1](https://github.com/MobilityData/gbfs/blob/v1.1/gbfs.md#gbfsjson)
9/// - [GBFS Specification V1.0](https://github.com/MobilityData/gbfs/blob/v1.0/gbfs.md#gbfsjson)
10pub type GBFSV1 = GBFSV11;
11
12/// GBFS Schema V1.1 Feeds Names
13#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
14pub enum GBFSV11FeedsName {
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    /// Station Information
26    #[serde(rename = "station_information")]
27    StationInformation,
28    /// Station Status
29    #[serde(rename = "station_status")]
30    StationStatus,
31    /// Free Bike Status
32    #[serde(rename = "free_bike_status")]
33    FreeBikeStatus,
34    /// System Hours
35    #[serde(rename = "system_hours")]
36    SystemHours,
37    /// System Alerts
38    #[serde(rename = "system_alerts")]
39    SystemAlerts,
40    /// System Calendar
41    #[serde(rename = "system_calendar")]
42    SystemCalendar,
43    /// System Regions
44    #[serde(rename = "system_regions")]
45    SystemRegions,
46    /// System Pricing Plans
47    #[serde(rename = "system_pricing_plans")]
48    SystemPricingPlans,
49}
50
51/// GBFS Schema V1.1 Feeds
52#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
53pub struct GBFSV11Feeds {
54    /// Name of the feed
55    pub name: GBFSV11FeedsName,
56    /// URL of the feed
57    pub url: String,
58}
59
60/// GBFS Schema V1.1 Feeds Data
61#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
62pub struct GBFSV11FeedsData {
63    /// List of feeds
64    pub feeds: Vec<GBFSV11Feeds>,
65}
66
67/// GBFS Schema V1.1 Interface
68#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
69pub struct GBFSV11 {
70    /// Last time the data in the feed was updated in POSIX time.
71    pub last_updated: u64,
72    /// Number of seconds before the data in the feed will be updated again.
73    pub ttl: u64,
74    /// GBFS version number (1.1).
75    pub version: String,
76    /// Response data in the form of name:value pairs.
77    pub data: BTreeMap<String, GBFSV11FeedsData>,
78}
79
80/// GBFS Schema V1.0 Feeds
81#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
82pub struct GBFSV10Feeds {
83    /// Name of the feed
84    pub name: String,
85    /// URL of the feed
86    pub url: String,
87}
88
89/// GBFS Schema V1.0 Feeds Data
90#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
91pub struct GBFSV10FeedsData {
92    /// List of feeds
93    feeds: Vec<GBFSV10Feeds>,
94}
95
96/// GBFS Schema V1.0 Interface
97#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
98pub struct GBFSV10 {
99    /// Last time the data in the feed was updated in POSIX time.
100    pub last_updated: u64,
101    /// Number of seconds before the data in the feed will be updated again.
102    pub ttl: u64,
103    /// Response data in the form of name:value pairs.
104    pub data: BTreeMap<String, GBFSV10FeedsData>,
105}