pub struct GeocodeService { /* private fields */ }Expand description
Implements a client for the Geocoding API.
§Example
async fn sample(
) -> anyhow::Result<()> {
let client = GeocodeService::builder().build().await?;
let response = client.geocode_address()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}§Service Description
A service for performing geocoding.
§Configuration
To configure GeocodeService use the with_* methods in the type returned
by builder(). The default configuration should
work for most applications. Common configuration changes include
- with_endpoint(): by default this client uses the global default endpoint
(
https://geocoding-backend.googleapis.com). Applications using regional endpoints or running in restricted networks (e.g. a network configured with Private Google Access with VPC Service Controls) may want to override this default. - with_credentials(): by default this client uses Application Default Credentials. Applications using custom authentication may need to override this default.
§Pooling and Cloning
GeocodeService holds a connection pool internally, it is advised to
create one and reuse it. You do not need to wrap GeocodeService in
an Rc or Arc to reuse it, because it
already uses an Arc internally.
Implementations§
Source§impl GeocodeService
impl GeocodeService
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for GeocodeService.
let client = GeocodeService::builder().build().await?;Sourcepub fn from_stub<T>(stub: impl Into<Arc<T>>) -> Selfwhere
T: GeocodeService + 'static,
pub fn from_stub<T>(stub: impl Into<Arc<T>>) -> Selfwhere
T: GeocodeService + 'static,
Creates a new client from the provided stub.
The most common case for calling this function is in tests mocking the client’s behavior.
Sourcepub fn geocode_address(&self) -> GeocodeAddress
pub fn geocode_address(&self) -> GeocodeAddress
This method performs an address geocode, which maps an address to a LatLng. It also provides structured information about the address.
§Example
use google_maps_geocode_v4::Result;
async fn sample(
client: &GeocodeService
) -> Result<()> {
let response = client.geocode_address()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn geocode_location(&self) -> GeocodeLocation
pub fn geocode_location(&self) -> GeocodeLocation
This method performs a location geocode, which maps a LatLng to an address. It also provides structured information about the address.
§Example
use google_maps_geocode_v4::Result;
async fn sample(
client: &GeocodeService
) -> Result<()> {
let response = client.geocode_location()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn geocode_place(&self) -> GeocodePlace
pub fn geocode_place(&self) -> GeocodePlace
This method performs a geocode lookup using a place ID.
§Example
use google_maps_geocode_v4::Result;
async fn sample(
client: &GeocodeService
) -> Result<()> {
let response = client.geocode_place()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Trait Implementations§
Source§impl Clone for GeocodeService
impl Clone for GeocodeService
Source§fn clone(&self) -> GeocodeService
fn clone(&self) -> GeocodeService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more