gistools/readers/gbfs/schema_v3/
system_alerts.rs

1use crate::readers::GBFSName;
2use alloc::{string::String, vec::Vec};
3use serde::{Deserialize, Serialize};
4
5/// # GBFS System Alerts Schema V3.1-RC & V3.0
6/// Describes ad-hoc changes to the system.
7///
8/// ## Links
9/// - [GBFS Specification V3.1-RC](https://github.com/MobilityData/gbfs/blob/v3.1-RC/gbfs.md#system_alertsjson)
10/// - [GBFS Specification V3.0](https://github.com/MobilityData/gbfs/blob/v3.0/gbfs.md#system_alertsjson)
11pub type GBFSSystemAlertsV3 = GBFSSystemAlertsV30;
12
13/// GBFS System Alerts Alert Type
14#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
15pub enum GBFSSystemAlertsAlertTypeV30 {
16    /// System Closure
17    #[serde(rename = "system_closure")]
18    SystemClosure,
19    /// Station Closure
20    #[serde(rename = "station_closure")]
21    StationClosure,
22    /// Station Move
23    #[serde(rename = "station_move")]
24    StationMove,
25    /// Other
26    #[default]
27    #[serde(rename = "other")]
28    Other,
29}
30
31/// GBFS System Alerts Alert Times
32#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
33pub struct GBFSSystemAlertsAlertTimesV30 {
34    /// Start time in POSIX time
35    pub start: u64,
36    /// End time in POSIX time
37    pub end: Option<u64>,
38}
39
40/// GBFS System Alerts Alert
41#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
42pub struct GBFSSystemAlertsAlertV30 {
43    /// Identifier for this alert.
44    pub alert_id: String,
45    /// Type of alert.
46    /// Possible values: 'system_closure', 'station_closure', 'station_move', 'other'.
47    pub r#type: GBFSSystemAlertsAlertTypeV30,
48    /// Array of objects indicating when the alert is in effect.
49    pub times: Option<Vec<GBFSSystemAlertsAlertTimesV30>>,
50    /// Array of identifiers of the stations for which this alert applies.
51    pub station_ids: Option<Vec<String>>,
52    /// Array of identifiers of the regions for which this alert applies.
53    pub region_ids: Option<Vec<String>>,
54    /// URL where customers can learn more information about this alert.
55    pub url: Option<Vec<GBFSName>>,
56    /// Short summary of this alert to be displayed to the customer.
57    pub summary: Vec<GBFSName>,
58    /// Detailed description of the alert.
59    pub description: Option<Vec<GBFSName>>,
60    /// Indicates the last time the info for the alert was updated in RFC3339 format.
61    /// **Format**: date-time
62    pub last_updated: Option<String>,
63}
64
65/// GBFS System Alerts Alerts
66#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
67pub struct GBFSSystemAlertsAlertsV30 {
68    /// Data containing ad-hoc alerts for the system.
69    pub alerts: Vec<GBFSSystemAlertsAlertV30>,
70}
71
72/// # GBFS System Alerts Schema V3.0
73/// Describes ad-hoc changes to the system.
74///
75/// ## Links
76/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v3.0/gbfs.md#system_alertsjson)
77#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
78pub struct GBFSSystemAlertsV30 {
79    /// Last time the data in the feed was updated in RFC3339 format.
80    /// **Format**: date-time
81    pub last_updated: String,
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.
86    /// **Const**: '3.0'
87    pub version: String,
88    /// Data object containing system alerts.
89    pub data: GBFSSystemAlertsAlertsV30,
90}