gistools/readers/gbfs/schema_v1/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 V1.1 OR GBFS Station Status Schema V1.0
6/// Describes the capacity and rental availability of the station.
7///
8/// ## Links
9/// - [GBFS Specification V1.1](https://github.com/MobilityData/gbfs/blob/v1.1/gbfs.md#station_statusjson)
10/// - [GBFS Specification V1.0](https://github.com/MobilityData/gbfs/blob/v1.0/gbfs.md#station_statusjson)
11pub type GBFSStationStatusV1 = GBFSStationStatusV11;
12
13/// GBFS Station Status Station
14#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
15pub struct GBFSStationStatusStationV11 {
16 /// The ID of the station
17 pub station_id: String,
18 /// The number of bikes available
19 pub num_bikes_available: u64,
20 /// The number of bikes disabled
21 pub num_bikes_disabled: Option<u64>,
22 /// The number of docks available
23 pub num_docks_available: u64,
24 /// The number of docks disabled
25 pub num_docks_disabled: Option<u64>,
26 /// Whether the station is installed
27 #[serde(deserialize_with = "gbfs_bool_or_int")]
28 pub is_installed: bool,
29 /// Whether the station is renting
30 #[serde(deserialize_with = "gbfs_bool_or_int")]
31 pub is_renting: bool,
32 /// Whether the station is returning
33 #[serde(deserialize_with = "gbfs_bool_or_int")]
34 pub is_returning: bool,
35 /// The last time the station was reported
36 pub last_reported: u64,
37}
38
39/// GBFS Station Status Data
40#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
41pub struct GBFSStationStatusDataV11 {
42 /// Data containing an array of station statuses.
43 pub stations: Vec<GBFSStationStatusStationV11>,
44}
45
46/// GBFS Station Status Schema V1.1 Interface
47#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
48pub struct GBFSStationStatusV11 {
49 /// Last time the data in the feed was updated in POSIX time.
50 pub last_updated: u64,
51 /// Number of seconds before the data in the feed will be updated again.
52 pub ttl: u64,
53 /// GBFS version number (1.1).
54 pub version: String,
55 /// Data containing an array of station statuses.
56 pub data: GBFSStationStatusDataV11,
57}
58
59/// GBFS Station Status Schema V1.0 Interface
60#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
61pub struct GBFSStationStatusV10 {
62 /// Last time the data in the feed was updated in POSIX time.
63 pub last_updated: u64,
64 /// Number of seconds before the data in the feed will be updated again.
65 pub ttl: u64,
66 /// Data containing an array of station statuses.
67 pub data: GBFSStationStatusDataV11,
68}