Skip to content

Commit 91b75ad

Browse files
committed
fix: Status enums weren't roundtripping
1 parent 9b7a94d commit 91b75ad

File tree

10 files changed

+121
-71
lines changed

10 files changed

+121
-71
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* Release notes are available on
44
[GitHub](https://github.com/leontoeides/google_maps/releases).
55

6+
# 3.7.2
7+
8+
* 2024-11-07: Corrected issue with `Status` enums not round-tripping through
9+
de-serialisation and re-serialisation.
10+
611
# 3.7.1
712

813
* 2024-10-15: Small tweaks to the features. Put back `enable-reqwest`.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "google_maps"
3-
version = "3.7.1"
3+
version = "3.7.2"
44
authors = ["Dylan Bowker <dylan.bowker@arkiteq.io>"]
55
edition = "2021"
66
categories = ["api-bindings"]
@@ -125,7 +125,7 @@ rust_decimal_macros = "1"
125125
serde = { version = "1.0", features = ["derive"] }
126126
simd-json = "0.14"
127127
stream_throttle = { version = "0.5", optional = true }
128-
thiserror = "1.0"
128+
thiserror = "2.0"
129129
tokio = { version = "1", optional = true, features = ["time"] }
130130
tracing = { version = "0.1", features = ["log"] }
131131

src/directions/response/status.rs

+22-12
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,42 @@ use phf::phf_map;
66
use serde::{Deserialize, Deserializer, Serialize};
77

88
// -----------------------------------------------------------------------------
9-
9+
//
1010
/// The `status` field within the Directions response object contains the
1111
/// [status](https://developers.google.com/maps/documentation/directions/intro#StatusCodes)
1212
/// of the request, and may contain debugging information to help you track down
1313
/// why the Directions service failed.
14-
1514
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
15+
#[serde(rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "SCREAMING_SNAKE_CASE"))]
1616
pub enum Status {
1717
/// Indicates that the provided request was invalid. Common causes of this
1818
/// status include an invalid parameter or parameter value.
19-
#[serde(alias = "INVALID_REQUEST")]
19+
#[serde(alias = "InvalidRequest")]
2020
InvalidRequest,
21+
2122
/// Indicates the requested route is too long and cannot be processed. This
2223
/// error occurs when more complex directions are returned. Try reducing the
2324
/// number of waypoints, turns, or instructions.
24-
#[serde(alias = "MAX_ROUTE_LENGTH_EXCEEDED")]
25+
#[serde(alias = "MaxRouteLengthExceeded")]
2526
MaxRouteLengthExceeded,
27+
2628
/// Indicates that too many `waypoints` were provided in the request. For
2729
/// applications using the Directions API as a web service, or the
2830
/// [directions service in the Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/directions),
2931
/// the maximum allowed number of `waypoints` is 25, plus the origin and
3032
/// destination.
31-
#[serde(alias = "MAX_WAYPOINTS_EXCEEDED")]
33+
#[serde(alias = "MaxWaypointsExceeded")]
3234
MaxWaypointsExceeded,
35+
3336
/// Indicates at least one of the locations specified in the request's
3437
/// origin, destination, or waypoints could not be geocoded.
35-
#[serde(alias = "NOT_FOUND")]
38+
#[serde(alias = "NotFound")]
3639
NotFound,
40+
3741
/// Indicates the response contains a valid `result`.
38-
#[serde(alias = "OK")]
42+
#[serde(alias = "Ok")]
3943
Ok,
44+
4045
/// Indicates any of the following:
4146
/// * The API key is missing or invalid.
4247
/// * Billing has not been enabled on your account.
@@ -47,22 +52,27 @@ pub enum Status {
4752
/// See the [Maps
4853
/// FAQ](https://developers.google.com/maps/faq#over-limit-key-error) to
4954
/// learn how to fix this.
50-
#[serde(alias = "OVER_DAILY_LIMIT")]
55+
56+
#[serde(alias = "OverDailyLimit")]
5157
OverDailyLimit,
58+
5259
/// Indicates the service has received too many requests from your
5360
/// application within the allowed time period.
54-
#[serde(alias = "OVER_QUERY_LIMIT")]
61+
#[serde(alias = "OverQueryLimit")]
5562
OverQueryLimit,
63+
5664
/// Indicates that the service denied use of the directions service by your
5765
/// application.
58-
#[serde(alias = "REQUEST_DENIED")]
66+
#[serde(alias = "RequestDenied")]
5967
RequestDenied,
68+
6069
/// Indicates a directions request could not be processed due to a server
6170
/// error. The request may succeed if you try again.
62-
#[serde(alias = "UNKNOWN_ERROR")]
71+
#[serde(alias = "UnknownError")]
6372
UnknownError,
73+
6474
/// Indicates no route could be found between the origin and destination.
65-
#[serde(alias = "ZERO_RESULTS")]
75+
#[serde(alias = "ZeroResults")]
6676
ZeroResults,
6777
} // enum
6878

src/distance_matrix/response/status.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,30 @@ use phf::phf_map;
66
use serde::{Deserialize, Deserializer, Serialize};
77

88
// -----------------------------------------------------------------------------
9-
9+
//
1010
/// The `status` fields within the response object contain the status of the
1111
/// request, and may contain useful debugging information. The Distance Matrix
1212
/// API returns a top-level status field, with information about the request in
1313
/// general, as well as a status field for each element field, with information
1414
/// about that particular origin-destination pairing.
15-
1615
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
16+
#[serde(rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "SCREAMING_SNAKE_CASE"))]
1717
pub enum Status {
1818
/// Indicates that the provided request was invalid. Common causes of this
1919
/// status include an invalid parameter or parameter value.
20-
#[serde(alias = "INVALID_REQUEST")]
20+
#[serde(alias = "InvalidRequest")]
2121
InvalidRequest,
22+
2223
/// Indicates that the product of origins and destinations exceeds the
2324
/// per-query
2425
/// [limit](https://developers.google.com/maps/documentation/distance-matrix/usage-and-billing).
25-
#[serde(alias = "MAX_ELEMENTS_EXCEEDED")]
26+
#[serde(alias = "MaxElementsExceeded")]
2627
MaxElementsExceeded,
28+
2729
/// Indicates the response contains a valid `result`.
28-
#[serde(alias = "OK")]
30+
#[serde(alias = "Ok")]
2931
Ok,
32+
3033
/// Indicates any of the following:
3134
/// * The API key is missing or invalid.
3235
/// * Billing has not been enabled on your account.
@@ -37,19 +40,22 @@ pub enum Status {
3740
/// See the [Maps
3841
/// FAQ](https://developers.google.com/maps/faq#over-limit-key-error) to
3942
/// learn how to fix this.
40-
#[serde(alias = "OVER_DAILY_LIMIT")]
43+
#[serde(alias = "OverDailyLimit")]
4144
OverDailyLimit,
45+
4246
/// Indicates the service has received too many requests from your
4347
/// application within the allowed time period.
44-
#[serde(alias = "OVER_QUERY_LIMIT")]
48+
#[serde(alias = "OverQueryLimit")]
4549
OverQueryLimit,
50+
4651
/// Indicates that the service denied use of the Distance Matrix service by
4752
/// your application.
48-
#[serde(alias = "REQUEST_DENIED")]
53+
#[serde(alias = "RequestDenied")]
4954
RequestDenied,
55+
5056
/// Indicates a Distance Matrix request could not be processed due to a
5157
/// server error. The request may succeed if you try again.
52-
#[serde(alias = "UNKNOWN_ERROR")]
58+
#[serde(alias = "UnknownError")]
5359
UnknownError,
5460
} // enum
5561

src/elevation/response/status.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ use phf::phf_map;
66
use serde::{Deserialize, Deserializer, Serialize};
77

88
// -----------------------------------------------------------------------------
9-
9+
//
1010
/// Indicates the status of the response.
11-
1211
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
12+
#[serde(rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "SCREAMING_SNAKE_CASE"))]
1313
pub enum Status {
1414
/// Indicates that the request was malformed.
15-
#[serde(alias = "INVALID_REQUEST")]
15+
#[serde(alias = "InvalidRequest")]
1616
InvalidRequest,
17+
1718
/// Indicates that the request was successful.
18-
#[serde(alias = "OK")]
19+
#[serde(alias = "Ok")]
1920
Ok,
21+
2022
/// Indicates any of the following:
2123
/// * The API key is missing or invalid.
2224
/// * Billing has not been enabled on your account.
@@ -27,16 +29,19 @@ pub enum Status {
2729
/// See the [Maps
2830
/// FAQ](https://developers.google.com/maps/faq#over-limit-key-error) to
2931
/// learn how to fix this.
30-
#[serde(alias = "OVER_DAILY_LIMIT")]
32+
#[serde(alias = "OverDailyLimit")]
3133
OverDailyLimit,
34+
3235
/// Indicates the requestor has exceeded quota.
33-
#[serde(alias = "OVER_QUERY_LIMIT")]
36+
#[serde(alias = "OverQueryLimit")]
3437
OverQueryLimit,
38+
3539
/// Indicates that the API did not complete the request.
36-
#[serde(alias = "REQUEST_DENIED")]
40+
#[serde(alias = "RequestDenied")]
3741
RequestDenied,
42+
3843
/// Indicates an unknown error.
39-
#[serde(alias = "UNKNOWN_ERROR")]
44+
#[serde(alias = "UnknownError")]
4045
UnknownError,
4146
} // enum
4247

src/geocoding/response/status.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ use phf::phf_map;
77
use serde::{Deserialize, Deserializer, Serialize};
88

99
// -----------------------------------------------------------------------------
10-
10+
//
1111
/// Indicates the status of the response.
1212
1313
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
14+
#[serde(rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "SCREAMING_SNAKE_CASE"))]
1415
pub enum Status {
1516
/// Generally indicates one of the following:
1617
/// * The query (`address`, `components` or `latlng`) is missing.
1718
/// * An invalid `result_type` or `location_type` was given.
18-
#[serde(alias = "INVALID_REQUEST")]
19+
#[serde(alias = "InvalidRequest")]
1920
InvalidRequest,
21+
2022
/// Indicates that no errors occurred; the address was successfully parsed
2123
/// and at least one geocode was returned.
22-
#[serde(alias = "OK")]
24+
#[serde(alias = "Ok")]
2325
Ok,
26+
2427
/// Indicates any of the following:
2528
/// * The API key is missing or invalid.
2629
/// * Billing has not been enabled on your account.
@@ -31,23 +34,27 @@ pub enum Status {
3134
/// See the [Maps
3235
/// FAQ](https://developers.google.com/maps/faq#over-limit-key-error) to
3336
/// learn how to fix this.
34-
#[serde(alias = "OVER_DAILY_LIMIT")]
37+
#[serde(alias = "OverDailyLimit")]
3538
OverDailyLimit,
39+
3640
/// Indicates the requestor has exceeded quota.
37-
#[serde(alias = "OVER_QUERY_LIMIT")]
41+
#[serde(alias = "OverQueryLimit")]
3842
OverQueryLimit,
43+
3944
/// Indicates that the API did not complete the request. Confirm that the
4045
/// request was sent over HTTPS instead of HTTP.
41-
#[serde(alias = "REQUEST_DENIED")]
46+
#[serde(alias = "RequestDenied")]
4247
RequestDenied,
48+
4349
/// Indicates that the request could not be processed due to a server error.
4450
/// The request may succeed if you try again.
45-
#[serde(alias = "UNKNOWN_ERROR")]
51+
#[serde(alias = "UnknownError")]
4652
UnknownError,
53+
4754
/// Indicates that the geocode was successful but returned no results. This
4855
/// may occur if the geocoder was passed a non-existent `address`. This may
4956
/// also occur if the geocoder was passed a `latlng` in a remote location.
50-
#[serde(alias = "ZERO_RESULTS")]
57+
#[serde(alias = "ZeroResults")]
5158
ZeroResults,
5259
} // enum
5360

src/places/place_autocomplete/response/status.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ use phf::phf_map;
77
use serde::{Deserialize, Deserializer, Serialize};
88

99
// -----------------------------------------------------------------------------
10-
10+
//
1111
/// Indicates the status of the response.
12-
1312
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
13+
#[serde(rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "SCREAMING_SNAKE_CASE"))]
1414
pub enum Status {
1515
/// Indicates the API request was malformed, generally due to the missing
1616
/// input parameter.
17-
#[serde(alias = "INVALID_REQUEST")]
17+
#[serde(alias = "InvalidRequest")]
1818
InvalidRequest,
19+
1920
/// Indicates that the request was successful.
20-
#[serde(alias = "OK")]
21+
#[serde(alias = "Ok")]
2122
Ok,
23+
2224
/// Indicates any of the following:
2325
/// * You have exceeded the QPS limits.
2426
/// * Billing has not been enabled on your account.
@@ -29,19 +31,22 @@ pub enum Status {
2931
///
3032
/// See the [Maps FAQ](https://developers.google.com/maps/faq#over-limit-key-error)
3133
/// for more information about how to resolve this error.
32-
#[serde(alias = "OVER_QUERY_LIMIT")]
34+
#[serde(alias = "OverQueryLimit")]
3335
OverQueryLimit,
36+
3437
/// Indicates that your request was denied, generally because:
3538
/// * The request is missing an API key.
3639
/// * The key parameter is invalid.
37-
#[serde(alias = "REQUEST_DENIED")]
40+
#[serde(alias = "RequestDenied")]
3841
RequestDenied,
42+
3943
/// Indicates an unknown error.
40-
#[serde(alias = "UNKNOWN_ERROR")]
44+
#[serde(alias = "UnknownError")]
4145
UnknownError,
46+
4247
/// Indicates that the search was successful but returned no results. This
4348
/// may occur if the search was passed a bounds in a remote location.
44-
#[serde(alias = "ZERO_RESULTS")]
49+
#[serde(alias = "ZeroResults")]
4550
ZeroResults,
4651
} // struct
4752

src/places/status.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,25 @@ use phf::phf_map;
77
use serde::{Deserialize, Deserializer, Serialize};
88

99
// -----------------------------------------------------------------------------
10-
10+
//
1111
/// Indicates the status of the response.
12-
1312
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
13+
#[serde(rename_all(serialize = "SCREAMING_SNAKE_CASE", deserialize = "SCREAMING_SNAKE_CASE"))]
1414
pub enum Status {
1515
/// Indicates that the request was successful.
16-
#[serde(alias = "OK")]
16+
#[serde(alias = "Ok")]
1717
Ok,
18+
1819
/// Indicates that the search was successful but returned no results. This
1920
/// may occur if the search was passed a `latlng` in a remote location.
20-
#[serde(alias = "ZERO_RESULTS")]
21+
#[serde(alias = "ZeroResults")]
2122
ZeroResults,
23+
2224
/// Indicates the API request was malformed, generally due to missing
2325
/// required query parameter (`location` or `radius`).
24-
#[serde(alias = "INVALID_REQUEST")]
26+
#[serde(alias = "InvalidRequest")]
2527
InvalidRequest,
28+
2629
/// Indicates any of the following:
2730
/// * You have exceeded the QPS limits.
2831
/// * Billing has not been enabled on your account.
@@ -33,19 +36,22 @@ pub enum Status {
3336
///
3437
/// See the [Maps FAQ](https://developers.google.com/maps/faq#over-limit-key-error)
3538
/// for more information about how to resolve this error.
36-
#[serde(alias = "OVER_QUERY_LIMIT")]
39+
#[serde(alias = "OverQueryLimit")]
3740
OverQueryLimit,
41+
3842
/// Indicates that your request was denied, generally because:
3943
/// * The request is missing an API key.
4044
/// * The `key` parameter is invalid.
41-
#[serde(alias = "REQUEST_DENIED")]
45+
#[serde(alias = "RequestDenied")]
4246
RequestDenied,
47+
4348
/// Indicates an unknown error.
44-
#[serde(alias = "UNKNOWN_ERROR")]
49+
#[serde(alias = "UnknownError")]
4550
UnknownError,
51+
4652
/// Indicates that that the referenced location, `place_id`, was not found
4753
/// in the Places database.
48-
#[serde(alias = "NOT_FOUND")]
54+
#[serde(alias = "NotFound")]
4955
NotFound,
5056
} // struct
5157

0 commit comments

Comments
 (0)