pub struct HttpClient {
pub client: Client,
pub base_url: Url,
/* private fields */
}Expand description
Shared HTTP client with base URL, optional rate limiter, and retry config.
This is the common structure used by all API clients to hold the configured reqwest client, base URL, and rate-limiting state.
Fields§
§client: ClientThe underlying reqwest HTTP client
base_url: UrlBase URL for API requests
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub async fn acquire_rate_limit(&self, path: &str, method: Option<&Method>)
pub async fn acquire_rate_limit(&self, path: &str, method: Option<&Method>)
Await rate limiter for the given endpoint path + method.
Sourcepub async fn acquire_concurrency(&self) -> Option<OwnedSemaphorePermit>
pub async fn acquire_concurrency(&self) -> Option<OwnedSemaphorePermit>
Acquire a concurrency permit, if a limiter is configured.
The returned permit must be held until the HTTP response has been
received. Dropping the permit releases the concurrency slot.
Returns None when no concurrency limit is set.
Sourcepub fn should_retry(
&self,
status: StatusCode,
attempt: u32,
retry_after: Option<&str>,
) -> Option<Duration>
pub fn should_retry( &self, status: StatusCode, attempt: u32, retry_after: Option<&str>, ) -> Option<Duration>
Check if a 429 response should be retried; returns backoff duration if yes.
When retry_after is Some, the server-provided delay is used instead of
the client-computed exponential backoff (clamped to max_backoff_ms).
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more