pub struct ClientConfig {
pub base_url: String,
pub api_key: Secret<String>,
pub timeout: Duration,
pub user_agent: String,
pub retry: RetryPolicy,
}Expand description
Shared configuration consumed by both the async and blocking clients.
The API key is wrapped in a Secret so it can never be logged or
serialized in cleartext. The derived Debug is safe: it prints
api_key: [REDACTED].
Fields§
§base_url: StringAPI base URL, without a trailing slash. Defaults to DEFAULT_BASE_URL.
api_key: Secret<String>Bearer API key.
timeout: DurationPer-request timeout. Defaults to 30 seconds.
user_agent: StringUser-Agent header value.
retry: RetryPolicyHow transient failures are retried. Defaults to RetryPolicy::default
(up to two retries with jittered exponential backoff).
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(api_key: impl Into<Secret<String>>) -> Self
pub fn new(api_key: impl Into<Secret<String>>) -> Self
Create a configuration from an API key, using production defaults.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the base URL (trailing slashes are trimmed).
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Override the per-request timeout.
Sourcepub fn with_user_agent(self, user_agent: impl Into<String>) -> Self
pub fn with_user_agent(self, user_agent: impl Into<String>) -> Self
Override the User-Agent header.
Sourcepub fn with_retry(self, retry: RetryPolicy) -> Self
pub fn with_retry(self, retry: RetryPolicy) -> Self
Override the retry policy. Pass RetryPolicy::none to disable retries.
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ClientConfig
impl RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnsafeUnpin for ClientConfig
impl UnwindSafe for ClientConfig
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