pub struct ProviderClient { /* private fields */ }Expand description
A generic provider HTTP client that consolidates the common request/response logic shared across all provider implementations (HERE, Google, TomTom, MapBox, Radar).
Each provider crate should use this instead of maintaining its own duplicated client.
The only configuration specific to each provider is the provider_name (used in
error messages) and the auth mechanism (injected via AuthProvider).
Implementations§
Source§impl ProviderClient
impl ProviderClient
Sourcepub fn new(
auth_provider: Arc<dyn AuthProvider>,
provider_name: &'static str,
) -> Self
pub fn new( auth_provider: Arc<dyn AuthProvider>, provider_name: &'static str, ) -> Self
Creates a new ProviderClient with the given authentication provider.
Sourcepub fn with_client_builder(
builder: ClientBuilder,
auth_provider: Arc<dyn AuthProvider>,
provider_name: &'static str,
) -> EveryMapResult<Self>
pub fn with_client_builder( builder: ClientBuilder, auth_provider: Arc<dyn AuthProvider>, provider_name: &'static str, ) -> EveryMapResult<Self>
Creates a ProviderClient with a custom reqwest::Client configuration.
Sourcepub fn set_verbose(&mut self, verbose: bool)
pub fn set_verbose(&mut self, verbose: bool)
Enable or disable verbose output (request/response logging to stderr).
Sourcepub fn is_verbose(&self) -> bool
pub fn is_verbose(&self) -> bool
Whether verbose mode is enabled.
Sourcepub fn provider_name(&self) -> &'static str
pub fn provider_name(&self) -> &'static str
The provider name (e.g., “here”, “google”, “tomtom”, “mapbox”, “radar”).
Sourcepub fn build_request(&self, method: Method, url: &str) -> RequestBuilder
pub fn build_request(&self, method: Method, url: &str) -> RequestBuilder
Builds a request to the given full URL with the specified HTTP method.
Sourcepub async fn request(&self, builder: RequestBuilder) -> EveryMapResult<Response>
pub async fn request(&self, builder: RequestBuilder) -> EveryMapResult<Response>
Sends a request, applying authentication first.
Returns an EveryMapError::HttpError for non-2xx status codes,
and EveryMapError::RateLimited for 429 responses.
Sourcepub async fn request_json<T: DeserializeOwned>(
&self,
builder: RequestBuilder,
) -> EveryMapResult<T>
pub async fn request_json<T: DeserializeOwned>( &self, builder: RequestBuilder, ) -> EveryMapResult<T>
Sends a request and deserializes the JSON response into T.
Reads the response body as text first, then deserializes with
serde_json::from_str. If deserialization fails, the error includes
a truncated excerpt of the raw response body for debugging.
Sourcepub async fn post_json<T: DeserializeOwned>(
&self,
url: &str,
body: &Value,
) -> EveryMapResult<T>
pub async fn post_json<T: DeserializeOwned>( &self, url: &str, body: &Value, ) -> EveryMapResult<T>
Sends a POST request with a JSON body and deserializes the response.