leontoeides / google_maps

An unofficial Google Maps Platform client library for the Rust programming language.
https://crates.io/crates/google_maps
Apache License 2.0
58 stars 24 forks source link

Add support for reqwest_maybe_middleware, make small structs Copy #20

Closed ChristianGoldapp closed 10 months ago

ChristianGoldapp commented 10 months ago

Our use-case required using Reqwest with middleware with the reqwest_middleware crate for caching purposes. I extended the library to use the reqwest_maybe_middleware crate internally, which is very lightweight by itself. If middleware is required, the reqwest_middleware crate can be included with the optional feature enable-reqwest-middleware, which is internally passed to reqwest_maybe_middleware.

To facilitate this internally, I created a new function get_requests to wrap a common pattern for using reqwest.

In order to make it easier to work with the produced responses in a polars DataFrame, I added the Copy trait to several objects that had a very small size, such as 2-tuples of ints and enums with no extra fields.

I also ran rustfmt on all changed files, which caused several unintended consequences for formatting. However, it may be good practice to run rustfmt (perhaps with custom settings) after every commit in the future, to prevent this and enforce consistent formatting.