Skip to main content

ClientBuilder

Struct ClientBuilder 

Source
pub struct ClientBuilder { /* private fields */ }
Expand description

Configures a LabelZoomClient.

Implementations§

Source§

impl ClientBuilder

Source

pub fn new() -> Self

A builder with the defaults.

Source

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.

Source

pub fn anonymous(self) -> Self

Forces the free tier: no credential, and no environment fallback.

Source

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.

Source

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.

Source

pub fn timeout(self, timeout: Duration) -> Self

Sets a per-request timeout. Only honoured by the bundled transport.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for ClientBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.