google_maps2/client/
mod.rs

1//! Contains the `GoogleMapsClient` struct and its associated traits. Use its
2//! implemented methods to set your _Google API key_ and other settings such as:
3//! _rate limiting_, _maxium retries_, & _retry delay times_ for your requests.
4
5// -----------------------------------------------------------------------------
6
7mod build;
8mod impls;
9#[cfg(feature = "enable-reqwest")]
10mod with_rate;
11#[cfg(feature = "enable-reqwest")]
12mod with_reqwest_client;
13
14// -----------------------------------------------------------------------------
15
16#[cfg(feature = "enable-reqwest")]
17use crate::request_rate::RequestRate;
18
19// -----------------------------------------------------------------------------
20//
21/// Use the `GoogleMapsClient` struct's implemented methods to set your _Google
22/// API key_ and other settings such as: _rate limiting_, _maxium retries_, &
23/// _retry delay times_ for your requests.
24///
25/// This structure contains your API key - the preferred way for authenticating
26/// with the Google Maps Platform APIs, your request rate limit settings, and
27/// your automatic retry settings.
28///
29/// How to use this structure's methods in a builder pattern:
30///
31/// ```rust
32/// let mut my_settings = GoogleMapsClient::new(YOUR_GOOGLE_API_KEY_HERE)
33///     .with_max_delay(std::time::Duration::from_secs(32))
34///     .with_max_retries(10)
35///     .with_rate(&Api::All, 1, std::time::Duration::from_secs(2))
36///     .build();
37/// ```
38
39#[derive(Clone, Debug)]
40pub struct GoogleMapsClient {
41    /// Your application's API key. This key identifies your application for
42    /// purposes of quota management. Learn how to [get a
43    /// key](https://developers.google.com/maps/documentation/geocoding/get-api-key).
44    pub key: String,
45
46    /// Rate limits for each of the Google Cloud Maps Platform APIs.
47    #[cfg(feature = "enable-reqwest")]
48    pub rate_limit: RequestRate,
49
50    /// Allows you to optionally provide your own pre-configured reqwest client
51    /// that will be used by the Google Maps client.
52    #[cfg(all(feature = "enable-reqwest", feature = "enable-reqwest-middleware"))]
53    pub reqwest_client: crate::reqwest_maybe_middleware::Client,
54
55    /// Allows you to optionally provide your own pre-configured reqwest client
56    /// that will be used by the Google Maps client.
57    #[cfg(all(feature = "enable-reqwest", not(feature = "enable-reqwest-middleware")))]
58    pub reqwest_client: reqwest::Client,
59} // struct