[][src]Struct google_maps::client_settings::ClientSettings

pub struct ClientSettings {
    pub key: String,
    pub max_retries: u8,
    pub max_backoff: u32,
    pub rate_limit: RequestRate,
}

Contains information used for authenticating with Google and other settings.

Fields

key: String

Your application's API key. This key identifies your application for purposes of quota management. Learn how to get a key. Contains the application's API key and other settings.

max_retries: u8

Certain network & server-side errors may be successful if retried with the same payload. This parameter sets the maximum number of times the client should retry before giving up.

max_backoff: u32

It's okay to continue retrying once you reach the max_backoff time. Retries after this point do not need to continue increasing backoff time. For example, if a client uses an max_backoff time of 64 seconds, then after reaching this value, the client can retry every 64 seconds. At some point, clients should be prevented from retrying infinitely.

How long clients should wait between retries and how many times they should retry depends on your use case and network conditions. For example, mobile clients of an application may need to retry more times and for longer intervals when compared to desktop clients of the same application.

rate_limit: RequestRate

Rate limits for each of the Google Cloud Maps Platform APIs.

Methods

impl ClientSettings[src]

pub fn finalize(&self) -> ClientSettings[src]

Completes the builder pattern into a final structure.

Arguments:

This method accepts no arguments.

impl ClientSettings[src]

pub fn new(key: &str) -> ClientSettings[src]

Initialize the settings needed for a Google Cloud Maps API transaction.

impl ClientSettings[src]

pub fn with_max_delay(&mut self, max_delay: Duration) -> &mut ClientSettings[src]

Sets the maximum delay between request retries upon consecutive failures.

Arguments

  • max_delay ‧ The maximum delay between request retries.

Description

Client will continue retrying once you the max_delay time is reached. Retries after this point will not continue increasing backoff time. For example, if a client uses an max_delay time of 64 seconds, then after reaching this value, the client can retry every 64 seconds.

How long clients should wait between retries and how many times they should retry depends on your use case and network conditions. For example, mobile clients of an application may need to retry more times and for longer intervals when compared to desktop clients of the same application.

Example:

  • Sets the maximum delay between request retries to 32 seconds:
.with_max_delay(Api::All, Duration::seconds(32))

impl ClientSettings[src]

pub fn with_max_retries(&mut self, max_retries: u8) -> &mut ClientSettings[src]

Sets the maximum number of retries upon a series of request failures.

Arguments

  • max_retries ‧ The maximum number of request retries.

Example:

  • Sets the maximum number of retries to 10:
.with_max_retries(10)

impl ClientSettings[src]

pub fn with_rate(
    &mut self,
    api: Api,
    requests: u16,
    per_duration: Duration
) -> &mut ClientSettings
[src]

Sets the rate limit for the specified API.

Arguments

  • api ‧ Which Google Maps API are you setting the rate limit for? For example, Api::Directions, Api::DistanceMatrix, Api::Elevation, Api::Geocoding, Api::TimeZone, and so on. The Api::All rate limit is applied to all Google Maps API requests in addition to the per-API rate limits.

  • requests ‧ Sets the maximum number of requests in the specified duration. For example, 2 requests per 1 hour.

  • per_duration ‧ Sets the duration window that the requests should be measured against. For example, 1 request per 1 minute.

Examples:

  • Sets the rate limit for all Google Maps API requests to 2 request per minute:
.with_rate(Api::All, 2, Duration::minutes(1))
  • Sets the rate limit for Google Maps Elevation API requests to 1 requests per second:
.with_rate(Api::Elevation, 1, Duration::seconds(1))
  • This method can be stacked:
.with_rate(Api::All, 1, Duration::seconds(1))
.with_rate(Api::Directions, 1, Duration::hours(1))
.with_rate(Api::TimeZone, 2, Duration::hours(1))

Trait Implementations

impl Clone for ClientSettings[src]

impl Debug for ClientSettings[src]

impl Eq for ClientSettings[src]

impl Ord for ClientSettings[src]

impl PartialEq<ClientSettings> for ClientSettings[src]

impl PartialOrd<ClientSettings> for ClientSettings[src]

impl StructuralEq for ClientSettings[src]

impl StructuralPartialEq for ClientSettings[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,