Struct google_maps::directions::response::route::Route
source · pub struct Route {
pub bounds: Bounds,
pub copyrights: String,
pub fare: Option<TransitFare>,
pub legs: Vec<Leg>,
pub overview_polyline: OverviewPolyline,
pub summary: String,
pub warnings: Vec<String>,
pub waypoint_order: Vec<u8>,
}
Expand description
A single route containing a set of legs in a
Response.
Note that though this object is “JSON-like,” it is not strictly JSON, as it
directly and indirectly includes LatLng
objects.
Fields§
§bounds: Bounds
The bounds for this route.
copyrights: String
Copyrights text to be displayed for this route.
fare: Option<TransitFare>
If present, contains the total fare (that is, the total ticket costs) on this route. This property is only returned for transit requests and only for routes where fare information is available for all transit legs.
legs: Vec<Leg>
An array of Legs
, each of which contains information about the steps
of which it is composed. There will be one leg for each stopover
waypoint or destination specified. So a route with no stopover waypoints
will contain one Leg
and a route with one stopover waypoint will
contain two.
overview_polyline: OverviewPolyline
An encoded polyline representation of the route. This polyline is an approximate (smoothed) path of the resulting directions.
summary: String
Contains a short textual description for the route, suitable for naming and disambiguating the route from alternatives.
warnings: Vec<String>
Contains an array of warnings to be displayed when showing these directions. You must handle and display these warnings yourself.
waypoint_order: Vec<u8>
If optimizeWaypoints
was set to true
, this field will contain the
re-ordered permutation of the input waypoints. For example, if the input
was:
Origin: Los Angeles
Waypoints: Dallas, Bangor, Phoenix
Destination: New York
and the optimized output was ordered as follows:
Origin: Los Angeles
Waypoints: Phoenix, Dallas, Bangor
Destination: New York
then this field will be an Array containing the values [2, 0, 1]. Note that the numbering of waypoints is zero-based.
If any of the input waypoints has stopover
set to false
, this field
will be empty, since route optimization is not available for such
queries.
Implementations§
source§impl Route
impl Route
sourcepub fn get_summary(&self) -> Option<&String>
pub fn get_summary(&self) -> Option<&String>
A helper function for destructuring (or serializing) the summary
field. If the summary text is populated, this function will return the
summary text in the String
format. If the summary text is empty,
this function will return None
.
let summary = route.get_summary();
sourcepub fn get_fare_currency(&self) -> Option<String>
pub fn get_fare_currency(&self) -> Option<String>
A helper function for destructuring (or serializing) the optional fare
field. If the fare struct is populated, this function will return the
currency code in the String
format. If the fare struct is empty,
this function will return None
.
let fare_currency = route.get_fare_currency();
sourcepub fn get_fare_value(&self) -> Option<Decimal>
pub fn get_fare_value(&self) -> Option<Decimal>
A helper function for destructuring (or serializing) the optional fare
field. If the fare struct is populated, this function will return the
value f64
. If the fare struct is empty, this function will return
None
.
let fare_value = route.get_fare_value();
sourcepub fn get_fare_text(&self) -> Option<&String>
pub fn get_fare_text(&self) -> Option<&String>
A helper function for destructuring (or serializing) the optional fare
field. If the fare struct is populated, this function will return the
text String
. If the fare struct is empty, this function will
return None
.
let fare_text = route.get_fare_text();
sourcepub fn get_warnings(&self) -> Option<String>
pub fn get_warnings(&self) -> Option<String>
A helper function for destructuring (or serializing) the warnings
field. If the warnings Vec
is populated, this function will return
the warnings as a String
in pipe-separated format. If the warnings
Vec is empty, this function will return None
.
let warnings = route.get_warning();
sourcepub fn get_waypoint_order(&self) -> Option<String>
pub fn get_waypoint_order(&self) -> Option<String>
A helper function for destructuring (or serializing) the
waypoint_order
field. If the waypoint_order
Vec
is populated, this
function will return the waypoint order as a String
in CSV format. If
the waypoint_order
Vec is empty, this function will return None
.
let waypoint_order = route.get_fare_text();
Trait Implementations§
source§impl<'de> Deserialize<'de> for Route
impl<'de> Deserialize<'de> for Route
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Route
impl PartialEq for Route
impl Eq for Route
impl StructuralPartialEq for Route
Auto Trait Implementations§
impl RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl UnwindSafe for Route
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.