pub struct ClientBuilder { /* private fields */ }Expand description
Builds an Api2Convert client. Obtain one via Api2Convert::builder.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
pub fn new() -> Self
Sourcepub fn api_key(self, key: impl Into<String>) -> Self
pub fn api_key(self, key: impl Into<String>) -> Self
The account API key. When unset, the API2CONVERT_API_KEY environment
variable is used at build time.
Sourcepub fn base_url(self, url: impl Into<String>) -> Self
pub fn base_url(self, url: impl Into<String>) -> Self
The API base URL (default DEFAULT_BASE_URL). A trailing / is trimmed.
Sourcepub fn timeout(self, d: Duration) -> Self
pub fn timeout(self, d: Duration) -> Self
The per-request network timeout for JSON calls (default 30s, min 1s).
Sourcepub fn max_retries(self, n: u32) -> Self
pub fn max_retries(self, n: u32) -> Self
The number of automatic retries for transient failures (default 2).
Sourcepub fn poll_interval(self, d: Duration) -> Self
pub fn poll_interval(self, d: Duration) -> Self
The first poll interval when waiting for a job (default 1s, floored to 500ms).
Sourcepub fn poll_max_interval(self, d: Duration) -> Self
pub fn poll_max_interval(self, d: Duration) -> Self
The upper bound the poll interval backs off to (default 5s).
Sourcepub fn poll_timeout(self, d: Duration) -> Self
pub fn poll_timeout(self, d: Duration) -> Self
How long to wait for a job before giving up (default 300s, capped at 14400s).
Sourcepub fn max_download_bytes(self, n: u64) -> Self
pub fn max_download_bytes(self, n: u64) -> Self
Cap the size of a downloaded file; a larger response yields a network
error instead of an unbounded read. 0 (the default) means unlimited.
Sourcepub fn http_sender(self, sender: Arc<dyn HttpSender>) -> Self
pub fn http_sender(self, sender: Arc<dyn HttpSender>) -> Self
Inject a custom HTTP transport (test seam / bring-your-own client).
Sourcepub fn sleeper(self, sleeper: Arc<dyn Sleeper>) -> Self
pub fn sleeper(self, sleeper: Arc<dyn Sleeper>) -> Self
Inject the delay function used by retry/poll backoff (test seam).
Sourcepub fn rng(self, rng: Arc<dyn Rng>) -> Self
pub fn rng(self, rng: Arc<dyn Rng>) -> Self
Inject the [0, 1) jitter source for backoff (test seam).
Sourcepub fn build(self) -> Result<Api2Convert>
pub fn build(self) -> Result<Api2Convert>
Resolve the configuration (clamping every knob) and build the client.
Fails with Api2ConvertError::Config if no API key is available.