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

source

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();
source

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();
source

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();
source

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();
source

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();
source

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 Clone for Route

source§

fn clone(&self) -> Route

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Route

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Route

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Hash for Route

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Route

source§

fn eq(&self, other: &Route) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Route

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Route

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,