pub struct ClientBuilder { /* private fields */ }Expand description
Configures a LabelZoomClient.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn api_key(self, api_key: impl Into<String>) -> Self
pub fn api_key(self, api_key: impl Into<String>) -> Self
Sets the credential: an lz_live_/lz_test_ key or a JWT.
Passing an empty string forces anonymous mode and suppresses the
LABELZOOM_API_KEY fallback, which is what you want when a config file may or may
not carry a key and you do not want the environment deciding.
Sourcepub fn anonymous(self) -> Self
pub fn anonymous(self) -> Self
Forces the free tier: no credential, and no environment fallback.
Sourcepub fn base_url(self, base_url: impl Into<String>) -> Self
pub fn base_url(self, base_url: impl Into<String>) -> Self
Overrides the API host. A path prefix is preserved, so a reverse proxy at
https://proxy.example.com/labelzoom works.
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
Sets the number of retries after the initial attempt. Defaults to 2, for 3 attempts in total. Zero disables retrying.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sets a per-request timeout. Only honoured by the bundled transport.
Sourcepub fn user_agent_suffix(self, suffix: impl Into<String>) -> Self
pub fn user_agent_suffix(self, suffix: impl Into<String>) -> Self
Appends a token to the SDK’s own User-Agent.
Appended, never prepended: the server parses a leading LabelZoomStudio/ as a
Studio version and silently changes PDF handling for versions <= 1.8.2.
Sourcepub fn transport(self, transport: Arc<dyn Transport>) -> Self
pub fn transport(self, transport: Arc<dyn Transport>) -> Self
Substitutes the HTTP backend. This is the seam to stub in tests – give it a
Transport that returns canned responses and no socket is ever opened.
Sourcepub fn sleeper(self, sleeper: Arc<dyn Sleeper>) -> Self
pub fn sleeper(self, sleeper: Arc<dyn Sleeper>) -> Self
Replaces the delay between retries. Substitute a recording no-op in tests so the retry paths cost no wall-clock time.
Sourcepub fn jitter(self, jitter: bool) -> Self
pub fn jitter(self, jitter: bool) -> Self
Turns retry jitter on or off. Off makes the backoff exactly 1s, 2s, 4s; leave it on in production, where it is what stops a fleet retrying in lockstep.
Sourcepub fn env_lookup(
self,
lookup: impl Fn(&str) -> Option<String> + Send + Sync + 'static,
) -> Self
pub fn env_lookup( self, lookup: impl Fn(&str) -> Option<String> + Send + Sync + 'static, ) -> Self
Replaces the environment lookup used to find LABELZOOM_API_KEY. Injecting it
keeps a developer’s real key out of a test’s outcome.
Sourcepub fn build(self) -> Result<LabelZoomClient, Error>
pub fn build(self) -> Result<LabelZoomClient, Error>
Builds the client.
§Errors
Returns Error::Validation when no transport is available – which can only
happen with default-features = false and no transport set.