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

Look at this Request struct for documentation on how to build your Geocoding API query. The methods implemented for this struct are what’s used to build your request. Reverse geocoding looks up a street address from latitude & longitude coorindates.

Implementations§

source§

impl<'a> ReverseRequest<'a>

source

pub fn build(&mut self) -> &'a mut ReverseRequest<'_>

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

§Arguments

This method accepts no arguments.

source§

impl<'a> ReverseRequest<'a>

source

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

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> ReverseRequest<'a>

source

pub async fn get(&mut self) -> Result<GeocodingResponse, GoogleMapsError>

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

§Arguments

This method accepts no arguments.

source§

impl<'a> ReverseRequest<'a>

source

pub const fn new( client: &'a GoogleMapsClient, latlng: LatLng ) -> ReverseRequest<'a>

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

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

  • latlng ‧ The latitude and longitude values specifying the location for which you wish to obtain the closest, human-readable address.

source§

impl<'a> ReverseRequest<'a>

source

pub fn query_url(&'a mut self) -> String

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> ReverseRequest<'a>

source

pub fn with_language( &'a mut self, language: Language ) -> &'a mut ReverseRequest<'_>

Specifies the language in which to return results.

§Arguments:
  • language - The language in which to return results.
§Description
  • See the list of supported languages. Google often updates the supported languages, so this list may not be exhaustive.

  • If language is not supplied, the geocoder attempts to use the preferred language as specified in the Accept-Language header, or the native language of the domain from which the request is sent.

  • The geocoder does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.

  • If a name is not available in the preferred language, the geocoder uses the closest match.

  • The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street and square respectively in Hungarian.

§Example:
  • Set language for result:
.with_language(Language::French)
source§

impl<'a> ReverseRequest<'a>

source

pub fn with_location_type( &'a mut self, location_type_element: LocationType ) -> &'a mut ReverseRequest<'_>

Restricts the results from the geocoder to the specified location type(s).

§Arguments:
  • location_type - A single location-type filter.
§Description:

A filter of one or more location types. If the parameter contains multiple location types, the API returns all addresses that match any of the types. A note about processing: The location_type parameter does not restrict the search to the specified location type(s). Rather, the location_type acts as a post-search filter: the API fetches all results for the specified latlng, then discards those results that do not match the specified location type(s).

  • LocationType::RoofTop returns only the addresses for which Google has location information accurate down to street address precision.

  • LocationType::RangeInterpolated returns only the addresses that reflect an approximation (usually on a road) interpolated between two precise points (such as intersections). An interpolated range generally indicates that rooftop geocodes are unavailable for a street address.

  • LocationType::GeometricCenter returns only geometric centers of a location such as a polyline (for example, a street) or polygon (region).

  • LocationType::Approximate returns only the addresses that are characterized as approximate.

If both result_type and location_type filters are present then the API returns only those results that match both the result_type and the location_type values. If none of the filter values are acceptable, the API returns ZERO_RESULTS.

§Examples:
  • A single location-type filter. This example restricts results to roof- top results:
.with_location_type(LocationType::RoofTop)
  • Multiple location type filters may be stacked together. This example restricts results to roof-top and range-interpolated:
.with_location_type(LocationType::RoofTop)
.with_location_type(LocationType::RangeInterpolated)
source

pub fn with_location_types( &'a mut self, location_type_slice: &[LocationType] ) -> &'a mut ReverseRequest<'_>

Restricts the results from the geocoder to the specified location type(s).

§Description

A filter of one or more location types. If the parameter contains multiple location types, the API returns all addresses that match any of the types.

If both result_type and location_type filters are present then the API returns only those results that match both the result_type and the location_type values. If none of the filter values are acceptable, the API returns ZERO_RESULTS.

§Example:
  • Alternatively, multiple location type filters may be passed in a single method call by passing a Vec. This example restricts results to roof-top and range-interpolated:
.with_location_types(&vec![
    LocationType::RoofTop,
    LocationType::RangeInterpolated,
])
source§

impl<'a> ReverseRequest<'a>

source

pub fn with_result_type( &'a mut self, result_type_element: PlaceType ) -> &'a mut ReverseRequest<'_>

Restricts the results from the geocoder to the specified result type(s).

§Arguments:
  • result_type - A single result type filter.
§Description:

A filter of one or more result types. If the parameter contains multiple result types, the API returns all addresses that match any of the types. A note about processing: The result_type parameter does not restrict the search to the specified location type(s). Rather, the result_type acts as a post-search filter: the API fetches all results for the specified latlng, then discards those results that do not match the specified result type(s). The following values are supported:

  • PlaceType::StreetAddress indicates a precise street address.

  • PlaceType::Route indicates a named route (such as “US 101”).

  • PlaceType::Intersection indicates a major intersection, usually of two major roads.

  • PlaceType::Political indicates a political entity. Usually, this type indicates a polygon of some civil administration.

  • PlaceType::Country indicates the national political entity, and is typically the highest order type returned by the Geocoder.

  • PlaceType::AdministrativeAreaLevel1 indicates a first-order civil entity below the country level. Within the United States, these administrative levels are states. Not all nations exhibit these administrative levels. In most cases, PlaceType::AdministrativeAreaLevel1 short names will closely match ISO 3166-2 subdivisions and other widely circulated lists; however this is not guaranteed as our geocoding results are based on a variety of signals and location data.

  • PlaceType::AdministrativeAreaLevel2 indicates a second-order civil entity below the country level. Within the United States, these administrative levels are counties. Not all nations exhibit these administrative levels.

  • PlaceType::AdministrativeAreaLevel3 indicates a third-order civil entity below the country level. This type indicates a minor civil division. Not all nations exhibit these administrative levels.

  • PlaceType::AdministrativeAreaLevel4 indicates a fourth-order civil entity below the country level. This type indicates a minor civil division. Not all nations exhibit these administrative levels.

  • PlaceType::AdministrativeAreaLevel5 indicates a fifth-order civil entity below the country level. This type indicates a minor civil division. Not all nations exhibit these administrative levels.

  • PlaceType::ColloquialArea indicates a commonly-used alternative name for the entity.

  • PlaceType::Locality indicates an incorporated city or town political entity.

  • PlaceType::Sublocality indicates a first-order civil entity below a locality. For some locations may receive one of the additional types: PlaceType::SublocalityLevel1 to PlaceType::SublocalityLevel5. Each sublocality level is a civil entity. Larger numbers indicate a smaller geographic area.

  • PlaceType::Neighborhood indicates a named neighborhood.

  • PlaceType::Premise indicates a named location, usually a building or collection of buildings with a common name.

  • PlaceType::Subpremise indicates a first-order entity below a named location, usually a singular building within a collection of buildings with a common name.

  • PlaceType::PostalCode indicates a postal code as used to address postal mail within the country.

  • PlaceType::NaturalFeature indicates a prominent natural feature.

  • PlaceType::Airport indicates an airport.

  • PlaceType::Park indicates a named park.

  • PlaceType::PointOfInterest indicates a named point of interest. Typically, these “POI“s are prominent local entities that don’t easily fit in another category, such as “Empire State Building” or “Eiffel Tower”.

If both result_type and location_type filters are present then the API returns only those results that match both the result_type and the location_type values. If none of the filter values are acceptable, the API returns ZERO_RESULTS.

§Examples:
  • A single result type filter. This example restricts results to the neighbourhood:
.with_result_type(PlaceType::Neighborhood)
  • Multiple component filters may be stacked together. This example restricts results to a neighborhood and a locality:
.with_result_type(PlaceType::Neighborhood)
.with_result_type(PlaceType::Locality)
source

pub fn with_result_types( &'a mut self, result_type_slice: &[PlaceType] ) -> &'a mut ReverseRequest<'_>

Restricts the results from the geocoder to the specified result type(s).

§Description

A filter of one or more result types. If the parameter contains multiple results types, the API returns all addresses that match any of the types.

If both result_type and location_type filters are present then the API returns only those results that match both the result_type and the location_type values. If none of the filter values are acceptable, the API returns ZERO_RESULTS.

§Example:
  • Alternatively, multiple result type filters may be passed in a single method call by passing a Vec. This example restricts results a neighborhood and a locality:
.with_components(&vec![
    PlaceType::Neighborhood,
    PlaceType::Locality,
])

Trait Implementations§

source§

impl<'a> Debug for ReverseRequest<'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 ReverseRequest<'a>

§

impl<'a> Send for ReverseRequest<'a>

§

impl<'a> Sync for ReverseRequest<'a>

§

impl<'a> Unpin for ReverseRequest<'a>

§

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

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