[][src]Struct google_maps::elevation::request::Request

pub struct Request { /* fields omitted */ }

Use this structure's methods to build a Time Zone API request.

Methods

impl Request[src]

pub fn build(&mut self) -> Result<&mut Request, Error>[src]

Builds the query string for the Google Maps Elevation API based on the input provided by the client.

Arguments:

This method accepts no arguments.

impl Request[src]

pub fn execute(&mut self) -> Result<Response, Error>[src]

Arguments:

This method accepts no arguments.

impl Request[src]

pub fn get(&self) -> Result<Response, Error>[src]

Performs the HTTP get request and returns the response to the caller.

Arguments:

This method accepts no arguments.

impl Request[src]

pub fn new(key: String) -> Request[src]

Initializes the builder pattern for a Time Zone API query with the required, non-optional parameters.

Arguments:

  • key - Your application's Google Cloud API key.

impl Request[src]

pub fn positional_request(&mut self, locations: Locations) -> &mut Request[src]

Adds the positional request parameters to the Elevation API query.

Arguments:

  • path - Defines a path on the earth for which to return elevation data. This parameter defines a set of two or more ordered latitude/longitude pairs defining a path along the surface of the earth. For more information, see Specifying Paths.
  • samples - Specifies the number of sample points along a path for which to return elevation data. The samples parameter divides the given path into an ordered set of equidistant points along the path.

Example:

let response = ElevationRequest::new(GOOGLE_API_KEY)
.positional_request(ElevationLocations::LatLngs(vec![
    // Denver, Colorado, the "Mile High City"
    LatLng { lat: 39.7391536, lng: -104.9847034 },
])).validate().unwrap().build().unwrap().get().unwrap();
let elevation = response.results.unwrap()[0].elevation;

impl Request[src]

pub fn sampled_path_request(
    &mut self,
    path: Locations,
    samples: u8
) -> &mut Request
[src]

Adds the sampled path request parameters to the Elevation API query.

Arguments:

  • locations - Defines the location(s) on the earth from which to return elevation data. This parameter takes either a single location, as a latitude/longitude pair, multiple latitude/longitude pairs, or an encoded polyline. For more information, see Specifying Locations.

Example:

let elevation = ElevationRequest::new(GOOGLE_API_KEY)
.sampled_path_request(
    ElevationLocations::LatLngs(vec![
        // Denver, Colorado
        LatLng { lat: 40.714728, lng: -73.998672 },
        // Death Valley, California
        LatLng { lat: -34.397, lng: -116.866667 },
    ]),
    // Number of samples
    4
).validate().unwrap().build().unwrap().get().unwrap();

impl Request[src]

pub fn validate(&mut self) -> Result<&mut Request, Error>[src]

Ensures the built query is valid. This function checks the combination of parameters to ensure that they make sense together and that Google Maps Directions API will accept them - i.e. it will not allow both a Positional Request and a Sampled Path Request in the same query. This function does not check parameter values for validity - i.e. it will not ensure Polylines or Latitudes/Longitudes are valid and well-formed.

Arguments:

This method accepts no arguments.

Trait Implementations

impl Clone for Request[src]

impl Debug for Request[src]

impl<'de> Deserialize<'de> for Request[src]

impl PartialEq<Request> for Request[src]

impl PartialOrd<Request> for Request[src]

impl Serialize for Request[src]

impl StructuralPartialEq for Request[src]

Auto Trait Implementations

impl RefUnwindSafe for Request

impl Send for Request

impl Sync for Request

impl Unpin for Request

impl UnwindSafe for Request

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.