pub struct Request<'a> { /* private fields */ }
Expand description

Look at this Request struct for documentation on how to build your Elevation API query. The methods implemented for this struct are what’s used to build your request.

Implementations§

source§

impl<'a> Request<'a>

source

pub fn build(&mut self) -> Result<&'a mut Request<'_>, Error>

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

Arguments:

This method accepts no arguments.

source§

impl<'a> Request<'a>

source

pub async fn execute(&'a mut self) -> Result<Response, Error>

Executes the query you’ve built.

Description:

My adventures in Rust became messy so I had to make this method. It wraps the .validate()?.build()?.get()? chain needed at the end of the builder pattern.

Arguments:

This method accepts no arguments.

source§

impl<'a> Request<'a>

source

pub fn for_positional_request( &'a mut self, location: LatLng ) -> &'a mut Request<'_>

Adds the positional request parameter to the Elevation API query.

Arguments:
  • location ‧ Defines the location on the earth from which to return elevation data. This parameter takes a single LatLng coordinate.
Example:
// Denver, Colorado, the "Mile High City"
.for_positional_request(LatLng::try_from_dec(dec!(39.7391536), dec!(-104.9847034))?)
source

pub fn for_positional_requests( &'a mut self, locations: Locations ) -> &'a mut Request<'_>

Adds a single positional request parameter 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:
.for_positional_requests(ElevationLocations::LatLngs(vec![
    // Denver, Colorado, the "Mile High City"
    LatLng::try_from_dec(dec!(39.7391536), dec!(-104.9847034))?,
    // Death Valley
    LatLng::try_from_dec(dec!(36.23998), dec!(-116.83171))?,
]))
source§

impl<'a> Request<'a>

source

pub fn for_sampled_path_request( &'a mut self, path: Locations, samples: u8 ) -> &'a mut Request<'_>

Adds the sampled path 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.

Examples:
  • 2 elevation samples between two points:
.for_sampled_path_request(
    Locations::LatLngs(vec![
        // Denver, Colorado
        LatLng::try_from_dec(dec!(40.714728), dec!(-73.998672))?,
        // Death Valley, California
        LatLng::try_from_dec(dec!(-34.397), dec!(-116.866667))?,
    ]),
    // Number of samples
    2
)
  • 4 elevation samples along a polyline:
.for_sampled_path_request(
    Locations::Polyline(String::from("gfo}EtohhUxD@bAxJmGF")),
    // Number of samples
    4
)
source§

impl<'a> Request<'a>

source

pub async fn get(&mut self) -> Result<Response, Error>

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

Arguments:

This method accepts no arguments.

source§

impl<'a> Request<'a>

source

pub fn new(client: &GoogleMapsClient) -> Request<'_>

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

Arguments:
  • client ‧ Your application’s Google Maps API client struct.
source§

impl<'a> Request<'a>

source

pub fn query_url(&'a mut self) -> Result<String, Error>

Returns the URL query string that represents the query you’ve built.

Description:

Returns the query string that will be sent to the Google Maps API. It is the result of the builder pattern. This method could be useful for records or logging. It could also be used for passing to your HTTP client of choice and executing the HTTP GET request yourself.

Arguments:

This method accepts no arguments.

source§

impl<'a> Request<'a>

source

pub fn validate(&mut self) -> Result<&'a mut Request<'_>, Error>

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§

source§

impl<'a> Debug for Request<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Request<'a>

§

impl<'a> Send for Request<'a>

§

impl<'a> Sync for Request<'a>

§

impl<'a> Unpin for Request<'a>

§

impl<'a> !UnwindSafe for Request<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere 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