gistools/readers/gbfs/schema_v2/
free_bike_status.rs

1use crate::readers::{GBFSRentalUri, gbfs_bool_or_int};
2use alloc::{string::String, vec::Vec};
3use s2json::MValue;
4use serde::{Deserialize, Serialize};
5
6/// # Free Bike Status Schema V2.3, V2.2, V2.1, OR V2.0
7/// Describes the vehicles that are available for rent.
8///
9/// ## Links
10/// - [GBFS Specification V2.3](https://github.com/MobilityData/gbfs/blob/v2.3/gbfs.md#free_bike_statusjson)
11/// - [GBFS Specification V2.2](https://github.com/MobilityData/gbfs/blob/v2.2/gbfs.md#free_bike_statusjson)
12/// - [GBFS Specification V2.1](https://github.com/MobilityData/gbfs/blob/v2.1/gbfs.md#free_bike_statusjson)
13/// - [GBFS Specification V2.0](https://github.com/MobilityData/gbfs/blob/v2.0/gbfs.md#free_bike_statusjson)
14pub type GBFSFreeBikeStatusV2 = GBFSFreeBikeStatusV23;
15
16/// Vehicle Equipment Type
17#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
18pub enum GBFSFreeBikeStatusVehicleEquipmentV2 {
19    /// Child Seat A
20    #[serde(rename = "child_seat_a")]
21    #[default]
22    ChildSeatA,
23    /// Child Seat B
24    #[serde(rename = "child_seat_b")]
25    ChildSeatB,
26    /// Child Seat C
27    #[serde(rename = "child_seat_c")]
28    ChildSeatC,
29    /// Winter Tires
30    #[serde(rename = "winter_tires")]
31    WinterTires,
32    /// Snow Chains
33    #[serde(rename = "snow_chains")]
34    SnowChains,
35}
36
37/// Free Bike Status Bike Schema V2.3 Interface
38#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, MValue)]
39pub struct GBFSFreeBikeStatusBikeV23 {
40    /// Rotating (as of v2.0) identifier of a vehicle.
41    pub bike_id: String,
42    /// The latitude of the vehicle.
43    /// **Minimum**: -90
44    /// **Maximum**: 90
45    pub lat: Option<f64>,
46    /// The longitude of the vehicle.
47    /// **Minimum**: -180
48    /// **Maximum**: 180
49    pub lon: Option<f64>,
50    /// Is the vehicle currently reserved?
51    #[serde(deserialize_with = "gbfs_bool_or_int")]
52    pub is_reserved: bool,
53    /// Is the vehicle currently disabled (broken)?
54    #[serde(deserialize_with = "gbfs_bool_or_int")]
55    pub is_disabled: bool,
56    /// Contains rental URIs for Android, iOS, and web (added in v1.1).
57    pub rental_uris: Option<GBFSRentalUri>,
58    /// The vehicle_type_id of this vehicle (added in v2.1-RC).
59    pub vehicle_type_id: Option<String>,
60    /// The last time this vehicle reported its status to the operator's backend in POSIX time (added in v2.1-RC).
61    /// **Minimum**: 1450155600
62    pub last_reported: Option<u64>,
63    /// The furthest distance in meters that the vehicle can travel without recharging or refueling with the vehicle's current charge or fuel (added in v2.1-RC).
64    /// **Minimum**: 0
65    pub current_range_meters: Option<f64>,
66    /// This value represents the current percentage, expressed from 0 to 1, of fuel or battery power remaining in the vehicle. Added in v2.3-RC.
67    /// **Minimum**: 0
68    /// **Maximum**: 1
69    pub current_fuel_percent: Option<f64>,
70    /// Identifier referencing the station_id if the vehicle is currently at a station (added in v2.1-RC2).
71    pub station_id: Option<String>,
72    /// The station_id of the station this vehicle must be returned to (added in v2.3-RC).
73    pub home_station_id: Option<String>,
74    /// The plan_id of the pricing plan this vehicle is eligible for (added in v2.2).
75    pub pricing_plan_id: Option<String>,
76    // /// List of vehicle equipment provided by the operator in addition to the accessories already provided in the vehicle. Added in v2.3.
77    // pub vehicle_equipment: Option<Vec<GBFSFreeBikeStatusVehicleEquipmentV2>>,
78    /// The date and time when any rental of the vehicle must be completed. Added in v2.3.
79    /// **Pattern**: `^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(([+-]([0-9]{2}):([0-9]{2}))|Z)$`
80    pub available_until: Option<String>,
81}
82
83/// Contains the list of bikes published by the auto-discovery file.
84#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
85pub struct GBFSFreeBikeStatusDataV23 {
86    /// An array of all bikes available for rent.
87    pub bikes: Vec<GBFSFreeBikeStatusBikeV23>,
88}
89
90/// # Free Bike Status V2.3
91/// Describes the vehicles that are available for rent (as of v2.1-RC2).
92///
93/// ## Links
94/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.3/gbfs.md#free_bike_statusjson)
95#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
96pub struct GBFSFreeBikeStatusV23 {
97    /// Last time the data in the feed was updated in POSIX time.
98    /// **Minimum**: 1450155600
99    pub last_updated: u64,
100    /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
101    /// **Minimum**: 0
102    pub ttl: u64,
103    /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
104    /// **Const**: 2.3
105    pub version: String,
106    /// Contains the list of bikes published by the auto-discovery file.
107    pub data: GBFSFreeBikeStatusDataV23,
108}
109
110/// Free Bike Status Bike Schema V2.2 Interface
111#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
112pub struct GBFSFreeBikeStatusBikeV22 {
113    /// Rotating (as of v2.0) identifier of a vehicle.
114    pub bike_id: String,
115    /// The latitude of the vehicle.
116    /// **Minimum**: -90
117    /// **Maximum**: 90
118    pub lat: Option<f64>,
119    /// The longitude of the vehicle.
120    /// **Minimum**: -180
121    /// **Maximum**: 180
122    pub lon: Option<f64>,
123    /// Is the vehicle currently reserved?
124    #[serde(deserialize_with = "gbfs_bool_or_int")]
125    pub is_reserved: bool,
126    /// Is the vehicle currently disabled (broken)?
127    #[serde(deserialize_with = "gbfs_bool_or_int")]
128    pub is_disabled: bool,
129    /// Contains rental URIs for Android, iOS, and web (added in v1.1).
130    pub rental_uris: Option<GBFSRentalUri>,
131    /// The vehicle_type_id of this vehicle (added in v2.1-RC).
132    pub vehicle_type_id: Option<String>,
133    /// The last time this vehicle reported its status to the operator's backend in POSIX time (added in v2.1-RC).
134    /// **Minimum**: 1450155600
135    pub last_reported: Option<u64>,
136    /// The furthest distance in meters that the vehicle can travel without recharging or refueling with the vehicle's current charge or fuel (added in v2.1-RC).
137    /// **Minimum**: 0
138    pub current_range_meters: Option<f64>,
139    /// Identifier referencing the station_id if the vehicle is currently at a station (added in v2.1-RC2).
140    pub station_id: Option<String>,
141    /// The plan_id of the pricing plan this vehicle is eligible for (added in v2.1-RC2).
142    pub pricing_plan_id: Option<String>,
143}
144
145/// Contains the list of bikes published by the auto-discovery file.
146#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
147pub struct GBFSFreeBikeStatusDataV22 {
148    /// An array of all bikes available for rent.
149    pub bikes: Vec<GBFSFreeBikeStatusBikeV22>,
150}
151
152/// # Free Bike Status V2.2
153/// Describes the vehicles that are available for rent (as of v2.1-RC2).
154///
155/// ## Links
156/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.2/gbfs.md#free_bike_statusjson)
157#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
158pub struct GBFSFreeBikeStatusV22 {
159    /// Last time the data in the feed was updated in POSIX time.
160    /// **Minimum**: 1450155600
161    pub last_updated: u64,
162    /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
163    /// **Minimum**: 0
164    pub ttl: u64,
165    /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
166    /// **Const**: 2.2
167    pub version: String,
168    /// Contains the list of bikes published by the auto-discovery file.
169    pub data: GBFSFreeBikeStatusDataV22,
170}
171
172/// Free Bike Status Bike Schema V2.1 Interface
173#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
174pub struct GBFSFreeBikeStatusBikeV21 {
175    /// Rotating (as of v2.0) identifier of a vehicle.
176    pub bike_id: String,
177    /// The latitude of the vehicle.
178    /// **Minimum**: -90
179    /// **Maximum**: 90
180    pub lat: Option<f64>,
181    /// The longitude of the vehicle.
182    /// **Minimum**: -180
183    /// **Maximum**: 180
184    pub lon: Option<f64>,
185    /// Is the vehicle currently reserved?
186    #[serde(deserialize_with = "gbfs_bool_or_int")]
187    pub is_reserved: bool,
188    /// Is the vehicle currently disabled (broken)?
189    #[serde(deserialize_with = "gbfs_bool_or_int")]
190    pub is_disabled: bool,
191    /// Contains rental URIs for Android, iOS, and web (added in v1.1).
192    pub rental_uris: Option<GBFSRentalUri>,
193    /// The vehicle_type_id of this vehicle (added in v2.1-RC).
194    pub vehicle_type_id: Option<String>,
195    /// The last time this vehicle reported its status to the operator's backend in POSIX time (added in v2.1-RC).
196    /// **Minimum**: 1450155600
197    pub last_reported: Option<u64>,
198    /// The furthest distance in meters that the vehicle can travel without recharging or refueling (added in v2.1-RC).
199    /// **Minimum**: 0
200    pub current_range_meters: Option<f64>,
201    /// Identifier referencing the station_id if the vehicle is currently at a station (added in v2.1-RC2).
202    pub station_id: Option<String>,
203}
204
205/// Contains the list of bikes published by the auto-discovery file.
206#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
207pub struct GBFSFreeBikeStatusDataV21 {
208    /// An array of all bikes available for rent.
209    pub bikes: Vec<GBFSFreeBikeStatusBikeV21>,
210}
211
212/// # Free Bike Status V2.1
213/// Describes the vehicles that are available for rent (as of v2.1-RC2).
214///
215/// ## Links
216/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.1/gbfs.md#free_bike_statusjson)
217#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
218pub struct GBFSFreeBikeStatusV21 {
219    /// Last time the data in the feed was updated in POSIX time.
220    /// **Minimum**: 1450155600
221    pub last_updated: u64,
222    /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
223    /// **Minimum**: 0
224    pub ttl: u64,
225    /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
226    /// **Const**: 2.1
227    pub version: String,
228    /// Contains the list of bikes published by the auto-discovery file.
229    pub data: GBFSFreeBikeStatusDataV21,
230}
231
232/// Free Bike Status Bike Schema V2.0 Interface
233#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
234pub struct GBFSFreeBikeStatusBikeV20 {
235    /// Rotating (as of v2.0) identifier of a vehicle.
236    pub bike_id: String,
237    /// The latitude of the vehicle.
238    /// **Minimum**: -90
239    /// **Maximum**: 90
240    pub lat: f64,
241    /// The longitude of the vehicle.
242    /// **Minimum**: -180
243    /// **Maximum**: 180
244    pub lon: f64,
245    /// Is the vehicle currently reserved?
246    #[serde(deserialize_with = "gbfs_bool_or_int")]
247    pub is_reserved: bool,
248    /// Is the vehicle currently disabled (broken)?
249    #[serde(deserialize_with = "gbfs_bool_or_int")]
250    pub is_disabled: bool,
251    /// Contains rental URIs for Android, iOS, and web (added in v1.1).
252    pub rental_uris: Option<GBFSRentalUri>,
253}
254
255/// Contains the list of bikes published by the auto-discovery file.
256#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
257pub struct GBFSFreeBikeStatusDataV20 {
258    /// An array of all bikes available for rent.
259    pub bikes: Vec<GBFSFreeBikeStatusBikeV20>,
260}
261
262/// # Free Bike Status V2.0
263/// Describes the vehicles that are not at a station and are available for rent.
264///
265/// ## Links
266/// - [GBFS Specification](https://github.com/MobilityData/gbfs/blob/v2.0/gbfs.md#free_bike_statusjson)
267pub struct GBFSFreeBikeStatusV20 {
268    /// Last time the data in the feed was updated in POSIX time.
269    /// **Minimum**: 1450155600
270    pub last_updated: u64,
271    /// Number of seconds before the data in the feed will be updated again (0 if the data should always be refreshed).
272    /// **Minimum**: 0
273    pub ttl: u64,
274    /// GBFS version number to which the feed conforms, according to the versioning framework (added in v1.1).
275    /// **Const**: 2.0
276    pub version: String,
277    /// Contains the list of bikes published by the auto-discovery file.
278    pub data: GBFSFreeBikeStatusDataV20,
279}