pub struct ClientBuilder { /* private fields */ }Expand description
Builder for Client. base_url and api_key are required; everything
else has a sensible default.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
pub fn new() -> Self
Sourcepub fn base_url(self, base_url: impl Into<String>) -> Self
pub fn base_url(self, base_url: impl Into<String>) -> Self
The control-plane’s base URL, e.g. https://cp.example.com. Must be
https://, unless the host is localhost/127.0.0.1/::1 (local
dev only) – every request sends Authorization: Bearer <api_key>,
a full-privilege, long-lived account credential, so an http:// URL
to anything else would put it on the wire in cleartext. Trailing
slashes are stripped.
Sourcepub fn api_key(self, api_key: impl Into<String>) -> Self
pub fn api_key(self, api_key: impl Into<String>) -> Self
A boxxkite account API key (bxk_live_...).
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Per-request timeout. Defaults to 30 seconds. Ignored if
ClientBuilder::http_client is also set – configure the timeout
on that client instead.
Sourcepub fn http_client(self, http_client: Client) -> Self
pub fn http_client(self, http_client: Client) -> Self
Supply a preconfigured reqwest::Client instead of letting this
builder construct one – e.g. one pointed at a wiremock mock
server in tests, or with custom TLS/proxy settings. Authentication
is still applied per-request via api_key regardless.
Sourcepub fn retry(self, retry: RetryConfig) -> Self
pub fn retry(self, retry: RetryConfig) -> Self
Opt in to automatic retry with exponential backoff for transient
failures. Off by default – a call fails on the first non-2xx or
transport error unless a policy is set here. See RetryConfig for
what is (and isn’t) retried, and RetryConfig::default for the
sensible defaults ClientBuilder::max_retries applies.
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
Shorthand for ClientBuilder::retry with the default backoff
(500ms base, 30s cap, full jitter, honors Retry-After) and just the
retry count changed. max_retries(0) disables retries (the default).
Sourcepub fn build(self) -> Result<Client, BoxxkiteError>
pub fn build(self) -> Result<Client, BoxxkiteError>
Validate the configuration and construct the Client.
§Errors
BoxxkiteError::Config if base_url/api_key weren’t set, or if
base_url isn’t a valid https:// (or localhost-only http://) URL.