gistools/readers/gbfs/schema_v1/
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 V1.1 OR Free Bike Status Schema V1.0
7/// Describes the vehicles that are available for rent.
8///
9/// ## Links
10/// - [GBFS Specification V1.1](https://github.com/MobilityData/gbfs/blob/v1.1/gbfs.md#free_bike_statusjson)
11/// - [GBFS Specification V1.0](https://github.com/MobilityData/gbfs/blob/v1.0/gbfs.md#free_bike_statusjson)
12pub type GBFSFreeBikeStatusV1 = GBFSFreeBikeStatusV11;
13
14/// Free Bike Status Schema V1.1 Interface
15#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, MValue)]
16pub struct GBFSFreeBikeV11 {
17    /// Bike ID
18    pub bike_id: String,
19    /// Latitude
20    pub lat: f64,
21    /// Longitude
22    pub lon: f64,
23    /// Is the bike reserved
24    #[serde(deserialize_with = "gbfs_bool_or_int")]
25    pub is_reserved: bool,
26    /// Is the bike disabled
27    #[serde(deserialize_with = "gbfs_bool_or_int")]
28    pub is_disabled: bool,
29    /// Rental URIs
30    pub rental_uris: Option<GBFSRentalUri>,
31}
32
33/// Data containing an array of bikes.
34#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
35pub struct GBFSFreeBikeDataV11 {
36    /// Data containing an array of bikes.
37    pub bikes: Vec<GBFSFreeBikeV11>,
38}
39
40/// Free Bike Status Schema V1.1 Interface
41#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
42pub struct GBFSFreeBikeStatusV11 {
43    /// Last time the data in the feed was updated in POSIX time.
44    pub last_updated: u64,
45    /// Number of seconds before the data in the feed will be updated again.
46    pub ttl: u64,
47    /// GBFS version number (1.1).
48    pub version: String,
49    /// Data containing an array of bikes.
50    pub data: GBFSFreeBikeDataV11,
51}
52
53/// Free Bike Status Schema V1.0 Interface
54#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
55pub struct GBFSFreeBikeV10 {
56    /// Bike ID
57    pub bike_id: String,
58    /// Latitude
59    pub lat: f64,
60    /// Longitude
61    pub lon: f64,
62    /// Is the bike reserved
63    #[serde(deserialize_with = "gbfs_bool_or_int")]
64    pub is_reserved: bool,
65    /// Is the bike disabled
66    #[serde(deserialize_with = "gbfs_bool_or_int")]
67    pub is_disabled: bool,
68}
69
70/// Data containing an array of bikes.
71#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
72pub struct GBFSFreeBikeDataV10 {
73    /// Data containing an array of bikes.
74    pub bikes: Vec<GBFSFreeBikeV10>,
75}
76
77/// Free Bike Status Schema V1.0 Interface
78#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
79pub struct GBFSFreeBikeStatusV10 {
80    /// Last time the data in the feed was updated in POSIX time.
81    pub last_updated: u64,
82    /// Number of seconds before the data in the feed will be updated again.
83    pub ttl: u64,
84    /// Data containing an array of bikes.
85    pub data: GBFSFreeBikeDataV10,
86}