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