gistools/readers/gbfs/schema_v3/station_status.rs
1use crate::readers::gbfs_bool_or_int;
2use alloc::{string::String, vec::Vec};
3use serde::{Deserialize, Serialize};
4
5/// # GBFS Station Status Schema V3.1-RC & V3.0
6/// Describes the capacity and rental availability of the station.
7///
8/// ## Links
9/// - [GBFS Specification V3.1-RC](https://github.com/MobilityData/gbfs/blob/v3.1-RC/gbfs.md#station_statusjson)
10/// - [GBFS Specification V3.0](https://github.com/MobilityData/gbfs/blob/v3.0/gbfs.md#station_statusjson)
11pub type GBFSStationStatusV3 = GBFSStationStatusV30;
12
13/// Vehicle Type
14#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
15pub struct GBFSStationStatusStationV30VehicleType {
16 /// Identifier of the vehicle type.
17 pub vehicle_type_id: String,
18 /// Number of vehicles of this type available at the station.
19 pub count: u64,
20}
21
22/// GBFS Station Status Station
23#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
24pub struct GBFSStationStatusStationV30 {
25 /// Identifier of the station.
26 pub station_id: String,
27 /// Number of vehicles physically available for rental at the station.
28 /// **Minimum**: 0
29 pub num_vehicles_available: u64,
30 /// Details of vehicles available by type at the station.
31 pub vehicle_types_available: Option<Vec<GBFSStationStatusStationV30VehicleType>>,
32 /// Number of disabled vehicles at the station.
33 /// **Minimum**: 0
34 pub num_vehicles_disabled: Option<u64>,
35 /// Number of functional docks physically at the station.
36 /// **Minimum**: 0
37 pub num_docks_available: Option<u64>,
38 /// Number of disabled but empty docks at the station.
39 /// **Minimum**: 0
40 pub num_docks_disabled: Option<u64>,
41 /// Indicates whether the station is installed on the street.
42 #[serde(deserialize_with = "gbfs_bool_or_int")]
43 pub is_installed: bool,
44 /// Indicates whether the station is currently renting vehicles.
45 #[serde(deserialize_with = "gbfs_bool_or_int")]
46 pub is_renting: bool,
47 /// Indicates whether the station is accepting vehicle returns.
48 #[serde(deserialize_with = "gbfs_bool_or_int")]
49 pub is_returning: bool,
50 /// Last reported status time in RFC3339 format.
51 /// **Format**: date-time
52 pub last_reported: String,
53
54 /// Details of docks available by vehicle type at the station.
55 pub vehicle_docks_available: Option<Vec<GBFSStationStatusStationV30VehicleType>>,
56}
57
58/// GBFS Station Status Data
59#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
60pub struct GBFSStationStatusDataV30 {
61 /// Data containing an array of station statuses.
62 pub stations: Vec<GBFSStationStatusStationV30>,
63}
64
65/// # GBFS Station Status Schema V3.0
66/// Describes the capacity and rental availability of the station.
67///
68/// ## Links
69/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v3.0/gbfs.md#station_statusjson)
70#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
71pub struct GBFSStationStatusV30 {
72 /// Last time the data in the feed was updated in RFC3339 format.
73 /// **Format**: date-time
74 pub last_updated: String,
75 /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
76 /// **Minimum**: 0
77 pub ttl: u64,
78 /// GBFS version number to which the feed conforms.
79 /// **Const**: '3.0'
80 pub version: String,
81 /// Data object containing station statuses.
82 pub data: GBFSStationStatusDataV30,
83}