Struct google_maps::directions::response::leg::Leg

source ·
pub struct Leg {
    pub arrival_time: Option<TransitTime>,
    pub departure_time: Option<TransitTime>,
    pub distance: DirectionsDistance,
    pub duration: DirectionsDuration,
    pub duration_in_traffic: Option<DirectionsDuration>,
    pub end_address: String,
    pub end_location: LatLng,
    pub start_address: String,
    pub start_location: LatLng,
    pub steps: Vec<Step>,
}
Expand description

A single leg consisting of a set of steps in a DirectionsResult. Some fields in the leg may not be returned for all requests. Note that though this result is “JSON-like,” it is not strictly JSON, as it directly and indirectly includes LatLng objects.

Fields§

§arrival_time: Option<TransitTime>

An estimated arrival time for this leg. Only applicable for TravelMode::Transit requests.

§departure_time: Option<TransitTime>

An estimated departure time for this leg. Only applicable for TravelMode::Transit requests.

§distance: DirectionsDistance

The total distance covered by this leg. This property may be undefined as the distance may be unknown.

§duration: DirectionsDuration

The total duration of this leg. This property may be undefined as the duration may be unknown.

§duration_in_traffic: Option<DirectionsDuration>

The total duration of this leg, taking into account the traffic conditions indicated by the with_traffic_model() method. This property may be undefined as the duration may be unknown. Only available to Premium Plan customers.

§end_address: String

The address of the destination of this leg.

§end_location: LatLng

The Directions Service calculates directions between locations by using the nearest transportation option (usually a road) at the start and end locations. end_location indicates the actual geocoded destination, which may be different than the end_location of the last step if, for example, the road is not near the destination of this leg.

§start_address: String

The address of the origin of this leg.

§start_location: LatLng

The Directions Service calculates directions between locations by using the nearest transportation option (usually a road) at the start and end locations. start_location indicates the actual geocoded origin, which may be different than the start_location of the first step if, for example, the road is not near the origin of this leg.

§steps: Vec<Step>

An array of Steps, each of which contains information about the individual steps in this leg.

Implementations§

source§

impl Leg

source

pub fn get_duration_in_traffic_text(&self) -> Option<&String>

A helper function for destructuring (or serializing) the optional duration_in_traffic field. If the Duration struct is populated, this function will return the text field as a String. If the Duration struct is empty, this function will return None.

let duration_in_traffic_text = leg.get_duration_in_traffic_text();
source

pub fn get_duration_in_traffic_value(&self) -> Option<i64>

A helper function for destructuring (or serializing) the optional duration_in_traffic field. If the Duration struct is populated, this function will return the value field as a time::Duration. If the Duration struct is empty, this function will return None.

let duration_in_traffic_value = leg.get_duration_in_traffic_value();
source

pub fn get_arrival_time_text(&self) -> Option<&String>

A helper function for destructuring (or serializing) the optional arrival_time field. If the Time struct is populated, this function will return the text field as a String. If the Time struct is empty, this function will return None.

let arrival_time_text = leg.get_arrival_time_text();
source

pub fn get_arrival_time_value(&self) -> Option<i64>

A helper function for destructuring (or serializing) the optional arrival_time field. If the Time struct is populated, this function will return the time_zone field as a String type. If the Time struct is empty, this function will return None.

let arrival_time_zone = leg.arrival_time_zone();
source

pub fn get_arrival_time_zone(&self) -> Option<String>

A helper function for destructuring (or serializing) the optional arrival_time field. If the Time struct is populated, this function will return the time field as a i64 UNIX timestamp. If the Time struct is empty, this function will return None.

let arrival_time_zone = leg.arrival_time_zone();
source

pub fn get_departure_time_text(&self) -> Option<&String>

A helper function for destructuring (or serializing) the optional departure_time field. If the Time struct is populated, this function will return the text field as a String. If the Time struct is empty, this function will return None.

let departure_time_text = leg.get_departure_time_text();
source

pub fn get_departure_time_value(&self) -> Option<i64>

A helper function for destructuring (or serializing) the optional departure_time field. If the Time struct is populated, this function will return the time_zone field as a String type. If the Time struct is empty, this function will return None.

let departure_time_zone = leg.departure_time_zone();
source

pub fn get_departure_time_zone(&self) -> Option<String>

A helper function for destructuring (or serializing) the optional departure_time field. If the Time struct is populated, this function will return the time field as a i64 UNIX timestamp. If the Time struct is empty, this function will return None.

let departure_time_zone = leg.departure_time_zone();

Trait Implementations§

source§

impl Clone for Leg

source§

fn clone(&self) -> Leg

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 Leg

source§

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

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

impl<'de> Deserialize<'de> for Leg

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 Leg

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 Leg

source§

fn eq(&self, other: &Leg) -> 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 Leg

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 Leg

source§

impl StructuralPartialEq for Leg

Auto Trait Implementations§

§

impl Freeze for Leg

§

impl RefUnwindSafe for Leg

§

impl Send for Leg

§

impl Sync for Leg

§

impl Unpin for Leg

§

impl UnwindSafe for Leg

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
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.
source§

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

source§

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>,