motis_openapi_sdk/models/
trip_segment.rs

1/*
2 * MOTIS API
3 *
4 * This is the MOTIS routing API.
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: felix@triptix.tech
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// TripSegment : trip segment between two stops to show a trip on a map
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct TripSegment {
17    #[serde(rename = "trips")]
18    pub trips: Vec<models::TripInfo>,
19    #[serde(rename = "routeColor", skip_serializing_if = "Option::is_none")]
20    pub route_color: Option<String>,
21    /// Transport mode for this leg
22    #[serde(rename = "mode")]
23    pub mode: models::Mode,
24    /// distance in meters
25    #[serde(rename = "distance")]
26    pub distance: f64,
27    #[serde(rename = "from")]
28    pub from: Box<models::Place>,
29    #[serde(rename = "to")]
30    pub to: Box<models::Place>,
31    /// departure time
32    #[serde(rename = "departure")]
33    pub departure: String,
34    /// arrival time
35    #[serde(rename = "arrival")]
36    pub arrival: String,
37    /// scheduled departure time
38    #[serde(rename = "scheduledDeparture")]
39    pub scheduled_departure: String,
40    /// scheduled arrival time
41    #[serde(rename = "scheduledArrival")]
42    pub scheduled_arrival: String,
43    /// Whether there is real-time data about this leg
44    #[serde(rename = "realTime")]
45    pub real_time: bool,
46    /// Google polyline encoded coordinate sequence (with precision 7) where the trip travels on this segment.
47    #[serde(rename = "polyline")]
48    pub polyline: String,
49}
50
51impl TripSegment {
52    /// trip segment between two stops to show a trip on a map
53    pub fn new(trips: Vec<models::TripInfo>, mode: models::Mode, distance: f64, from: models::Place, to: models::Place, departure: String, arrival: String, scheduled_departure: String, scheduled_arrival: String, real_time: bool, polyline: String) -> TripSegment {
54        TripSegment {
55            trips,
56            route_color: None,
57            mode,
58            distance,
59            from: Box::new(from),
60            to: Box::new(to),
61            departure,
62            arrival,
63            scheduled_departure,
64            scheduled_arrival,
65            real_time,
66            polyline,
67        }
68    }
69}
70