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

Look at this Request struct for documentation on how to build your Text Search 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) -> &'a mut Request<'_>

Builds the query string for the Google Maps Places API Text Search query 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<TextSearchResponse, 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> Request<'a>

source

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

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 is_open_now(&'a mut self, opennow: bool) -> &'a mut Request<'_>

Adds “open now” filter to the Places API Text Search query.

§Arguments
  • opennow ‧ Returns only those places that are open for business at the time the query is sent. Places that do not specify opening hours in the Google Places database will not be returned if you include this parameter in your query.
source§

impl<'a> Request<'a>

source

pub const fn new( client: &GoogleMapsClient, query: String, radius: u32 ) -> Request<'_>

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

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

  • query ‧ The text string on which to search, for example: “restaurant” or “123 Main Street”. This must a place name, address, or category of establishments. Any other types of input can generate errors and are not guaranteed to return valid results. The Google Places service will return candidate matches based on this string and order the results based on their perceived relevance.

  • radius ‧ Defines the distance (in meters) within which to return place results. You may bias results to a specified circle by passing a location and a radius parameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed.

The radius will automatically be clamped to a maximum value depending on the type of search and other parameters.

  • Autocomplete: 50,000 meters
  • Nearby Search:
    • with keyword or name: 50,000 meters
    • without keyword or name
      • Up to 50,000 meters, adjusted dynamically based on area density, independent of rankby parameter.
      • When using rankby=distance, the radius parameter will not be accepted, and will result in an INVALID_REQUEST.
  • Query Autocomplete: 50,000 meters
  • Nearby Search: 50,000 meters
source§

impl<'a> Request<'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 Places 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 with_language(&'a mut self, language: Language) -> &'a mut Request<'_>

Adds the language parameter to the Places API Text Search query.

§Arguments
  • language ‧ The language in which to return results.

    • 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 API attempts to use the preferred language as specified in the Accept-Language header.

    • The API 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 API 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 in Hungarian.

source§

impl<'a> Request<'a>

source

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

Adds the location and radius parameters to the Places API Text Search query.

§Arguments
  • location ‧ The point around which to retrieve place information. This must be specified as latitude,longitude.

The location parameter may be overriden if the query contains an explicit location such as Market in Barcelona. Using quotes around the query may also influence the weight given to the location and radius.

source§

impl<'a> Request<'a>

source

pub fn with_max_price(&'a mut self, maxprice: u8) -> &'a mut Request<'_>

Adds the maximum price to the Places API Text Search query.

§Arguments
  • maxprice ‧ Restricts results to only those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive. The exact amount indicated by a specific value will vary from region to region.
source§

impl<'a> Request<'a>

source

pub fn with_min_price(&'a mut self, minprice: u8) -> &'a mut Request<'_>

Adds the minimum price to the Places API Text Search query.

§Arguments
  • minprice ‧ Restricts results to only those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive. The exact amount indicated by a specific value will vary from region to region.
source§

impl<'a> Request<'a>

source

pub fn with_pagetoken(&'a mut self, pagetoken: String) -> &'a mut Request<'_>

Adds the page token parameter to the Places API Text Search query.

§Arguments
  • pagetoken ‧ Returns up to 20 results from a previously run search. Setting a pagetoken parameter will execute a search with the same parameters used previously — all parameters other than pagetoken will be ignored.
source§

impl<'a> Request<'a>

source

pub fn with_region(&'a mut self, region: Region) -> &'a mut Request<'_>

Adds the region parameter to the Places API Text Search query.

§Arguments
  • region ‧ The region code, specified as a ccTLD (“top-level domain”) two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom’s ccTLD is “uk” (.co.uk) while its ISO 3166-1 code is “gb” (technically for the entity of “The United Kingdom of Great Britain and Northern Ireland”).
source§

impl<'a> Request<'a>

source

pub fn with_type(&'a mut self, place_type: PlaceType) -> &'a mut Request<'_>

Adds the types parameter to the Places API Text Search query.

§Arguments
  • type ‧ Restricts the results to places matching the specified type. Only one type may be specified. If more than one type is provided, all types following the first entry are ignored.

type=hospital|pharmacy|doctor becomes type=hospital type=hospital,pharmacy,doctor is ignored entirely

See the list of supported types.

Note: Adding both keyword and type with the same value (keyword=cafe&type=cafe or keyword=parking&type=parking) can yield ZERO_RESULTS.

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