Struct google_maps::elevation::request::Request
source · 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>
impl<'a> Request<'a>
sourcepub async fn execute(&'a mut self) -> Result<Response, Error>
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>
impl<'a> Request<'a>
sourcepub fn for_positional_request(
&'a mut self,
location: LatLng
) -> &'a mut Request<'_>
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 singleLatLng
coordinate.
Example:
// Denver, Colorado, the "Mile High City"
.for_positional_request(LatLng::try_from_dec(dec!(39.7391536), dec!(-104.9847034))?)
sourcepub fn for_positional_requests(
&'a mut self,
locations: Locations
) -> &'a mut Request<'_>
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>
impl<'a> Request<'a>
sourcepub fn for_sampled_path_request(
&'a mut self,
path: Locations,
samples: u8
) -> &'a mut Request<'_>
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>
impl<'a> Request<'a>
sourcepub fn new(client: &GoogleMapsClient) -> Request<'_>
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>
impl<'a> Request<'a>
sourcepub fn query_url(&'a mut self) -> Result<String, Error>
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>
impl<'a> Request<'a>
sourcepub fn validate(&mut self) -> Result<&'a mut Request<'_>, Error>
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.