ClientBuilder

Struct ClientBuilder 

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

Implementations§

Source§

impl ClientBuilder

Source

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

Sets the Alpaca API key.

Source

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

Sets the Alpaca API secret key.

Source

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

Overrides the default data API base URL.

Source

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

Sets the request timeout for the internally constructed reqwest::Client.

Building fails if reqwest_client(...) is also used because the injected client owns its own timeout configuration.

Source

pub fn reqwest_client(self, reqwest_client: Client) -> Self

Injects a preconfigured reqwest::Client for advanced transport tuning.

The injected client owns reqwest-level behavior such as connection pooling, proxy behavior, default headers, and timeout settings. Build validation rejects conflicting builder settings such as timeout(...).

Source

pub fn observer(self, observer: Arc<dyn TransportObserver>) -> Self

Registers an immutable observer for successful transport responses.

Observers receive endpoint metadata only. They cannot change request execution or response shaping.

Source

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

Sets the maximum number of retry attempts for one request.

This applies to server-error retries by default. HTTP 429 retries only participate when Self::retry_on_429 is enabled.

Source

pub fn retry_on_429(self, retry_on_429: bool) -> Self

Enables or disables automatic retries on HTTP 429 responses.

This setting is disabled by default and affects only 429 responses. It does not automatically enable honoring Retry-After.

Source

pub fn respect_retry_after(self, respect_retry_after: bool) -> Self

Enables or disables honoring the Retry-After response header.

This setting only participates when 429 retries are enabled with Self::retry_on_429. If a 429 response omits Retry-After, the transport falls back to the configured backoff schedule.

Source

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

Sets the base retry backoff used by the shared HTTP transport.

Source

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

Sets the maximum retry backoff used by the shared HTTP transport.

Source

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

Adds a bounded random delay on top of each computed retry wait.

Jitter helps concurrent callers avoid retrying in lockstep. The transport keeps the added delay within the configured retry budget and maximum backoff constraints.

Source

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

Sets an optional elapsed-time budget for one request’s retry loop.

The transport subtracts the request’s retry-loop elapsed time from this budget before each retry decision. The remaining budget then caps each scheduled retry wait, including waits derived from Retry-After and waits with jitter enabled.

Source

pub fn credentials_from_env(self) -> Result<Self, Error>

Loads credentials from APCA_API_KEY_ID and APCA_API_SECRET_KEY.

If both variables are unset, the builder is left unchanged. If only one side is set, this returns Error::InvalidConfiguration.

Source

pub fn credentials_from_env_names( self, api_key_var: &str, secret_key_var: &str, ) -> Result<Self, Error>

Loads credentials from the provided environment variable names.

If both variables are unset, the builder is left unchanged. If only one side is set, this returns Error::InvalidConfiguration.

Source

pub fn max_in_flight(self, max_in_flight: usize) -> Self

Sets the maximum number of concurrent in-flight requests.

Source

pub fn build(self) -> Result<Client, Error>

Validates configuration and builds a Client.

Credentials must be provided as a pair or omitted as a pair.

Trait Implementations§

Source§

impl Clone for ClientBuilder

Source§

fn clone(&self) -> ClientBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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