Skip to main content

ClientBuilder

Struct ClientBuilder 

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

Builds an Api2Convert client. Obtain one via Api2Convert::builder.

Implementations§

Source§

impl ClientBuilder

Source

pub fn new() -> Self

Source

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.

Source

pub fn base_url(self, url: impl Into<String>) -> Self

The API base URL (default DEFAULT_BASE_URL). A trailing / is trimmed.

Source

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

The per-request network timeout for JSON calls (default 30s, min 1s).

Source

pub fn max_retries(self, n: u32) -> Self

The number of automatic retries for transient failures (default 2).

Source

pub fn poll_interval(self, d: Duration) -> Self

The first poll interval when waiting for a job (default 1s, floored to 500ms).

Source

pub fn poll_max_interval(self, d: Duration) -> Self

The upper bound the poll interval backs off to (default 5s).

Source

pub fn poll_timeout(self, d: Duration) -> Self

How long to wait for a job before giving up (default 300s, capped at 14400s).

Source

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.

Source

pub fn http_sender(self, sender: Arc<dyn HttpSender>) -> Self

Inject a custom HTTP transport (test seam / bring-your-own client).

Source

pub fn sleeper(self, sleeper: Arc<dyn Sleeper>) -> Self

Inject the delay function used by retry/poll backoff (test seam).

Source

pub fn rng(self, rng: Arc<dyn Rng>) -> Self

Inject the [0, 1) jitter source for backoff (test seam).

Source

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.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more