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 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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HttpClient
impl !RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl UnsafeUnpin for HttpClient
impl !UnwindSafe for HttpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more