Skip to main content

ClientBuilder

Struct ClientBuilder 

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

Configures a Client.

Implementations§

Source§

impl ClientBuilder

Source

pub fn credentials(self, credentials: impl Credentials + 'static) -> Self

Sets the credentials, instead of taking them from the environment or the CLI’s session.

Source

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

Sends calls to a region’s front door, {service}.{region}.origincloudapis.eu, for the services that have one. It overrides ORIGINCLOUD_REGION; an empty region uses the regionless endpoint. A region, from either, is [a-z0-9-]+, such as eu-central1: ClientBuilder::build refuses any other.

Source

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

Sends the calls of every service to one base URL, such as a test server’s, instead of the service’s own host. ClientBuilder::build refuses one that isn’t an absolute URL with a host.

Source

pub fn http_client(self, http: Client) -> Self

Sets the HTTP client calls are sent with. Its timeout, if any, bounds each attempt.

Source

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

Adds a product, such as my-tool/1.2, to the User-Agent header.

Source

pub fn max_attempts(self, attempts: u32) -> Self

Sets how often a retryable call is sent at most, the first attempt included; 1 turns retries off. The default is 5.

Source

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

Bounds each attempt of a call by timeout; an attempt that takes longer fails as a transport error, which a safe call retries. By default, only the HTTP client’s own timeout, if any, bounds it.

Waiting on an operation asks the API to wait less than this, so that a wait call doesn’t time out on the way; see ClientBuilder::operation_wait.

Source

pub fn operation_wait(self, wait: Duration) -> Self

Sets how long one call of Operation::wait asks the API to wait for the operation before answering with it as it is, in whole seconds, at least one; the default, and the most the API waits, is a minute. With a ClientBuilder::timeout, a call asks for a second less than it at most. A wait call that times out all the same, such as under the HTTP client’s own timeout, counts as the operation not being done yet, and the next one is sent.

Source

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

The client. It fails when no credentials are found or an option is invalid.

Trait Implementations§

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> 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, 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, !>

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