gistools/readers/gbfs/schema_v1/
system_alerts.rs

1use alloc::{string::String, vec::Vec};
2use serde::{Deserialize, Serialize};
3
4/// # GBFS System Alerts Schema V1.1 OR GBFS System Alerts Schema V1.0
5/// Describes ad-hoc changes to the system.
6///
7/// ## Links
8/// - [GBFS Specification V1.1](https://github.com/MobilityData/gbfs/blob/v1.1/gbfs.md#system_alertsjson)
9/// - [GBFS Specification V1.0](https://github.com/MobilityData/gbfs/blob/v1.0/gbfs.md#system_alertsjson)
10pub type GBFSSystemAlertsV1 = GBFSSystemAlertsV11;
11
12/// GBFS System Alerts Alert Type
13#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
14pub enum GBFSSystemAlertsAlertTypeV11 {
15    /// System Closure
16    #[serde(rename = "SYSTEM_CLOSURE")]
17    SystemClosure,
18    /// Station Closure
19    #[serde(rename = "STATION_CLOSURE")]
20    StationClosure,
21    /// Station Move
22    #[serde(rename = "STATION_MOVE")]
23    StationMove,
24    /// Other
25    #[default]
26    #[serde(rename = "OTHER")]
27    Other,
28}
29
30/// GBFS System Alerts Alert Times
31#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
32pub struct GBFSSystemAlertsAlertTimesV11 {
33    /// Start time in POSIX time
34    pub start: u64,
35    /// End time in POSIX time
36    pub end: Option<u64>,
37}
38
39/// GBFS System Alerts Alert
40#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
41pub struct GBFSSystemAlertsAlertV1 {
42    /// Alert ID
43    pub alert_id: String,
44    /// Alert type
45    pub r#type: GBFSSystemAlertsAlertTypeV11,
46    /// List of times when the alert is active
47    pub times: Option<Vec<GBFSSystemAlertsAlertTimesV11>>,
48    /// List of affected stations
49    pub station_ids: Option<Vec<String>>,
50    /// List of affected regions
51    pub regions_ids: Option<Vec<String>>,
52    /// URL
53    pub url: Option<String>,
54    /// Summary
55    pub summary: String,
56    /// Description
57    pub description: Option<String>,
58    /// Last time the alert was updated
59    pub last_updated: Option<u64>,
60}
61
62/// GBFS System Alerts Alerts
63#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
64pub struct GBFSSystemAlertsAlertsV1 {
65    /// Data containing ad-hoc alerts for the system.
66    pub alerts: Vec<GBFSSystemAlertsAlertV1>,
67}
68
69/// GBFS System Alerts Schema V1.1 Interface
70#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
71pub struct GBFSSystemAlertsV11 {
72    /// Last time the data in the feed was updated in POSIX time.
73    pub last_updated: u64,
74    /// Number of seconds before the data in the feed will be updated again.
75    pub ttl: u64,
76    /// GBFS version number (1.1).
77    pub version: String,
78    /// Data containing ad-hoc alerts for the system.
79    pub data: GBFSSystemAlertsAlertsV1,
80}
81
82/// GBFS System Alerts Schema V1.0 Interface
83#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
84pub struct GBFSSystemAlertsV10 {
85    /// Last time the data in the feed was updated in POSIX time.
86    pub last_updated: u64,
87    /// Number of seconds before the data in the feed will be updated again.
88    pub ttl: u64,
89    /// Data containing ad-hoc alerts for the system.
90    pub data: GBFSSystemAlertsAlertsV1,
91}