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 timeout_idle(self, limit: Duration) -> Self

How long an exchange may sit without progress, for requests that set no Request::timeout. Default 30 s.

Source

pub fn timeout_total(self, limit: Duration) -> Self

How long a whole request may take, redirects, challenges and body included. Default none. A request’s own Request::timeout_total wins.

Source

pub fn redirects(self, redirects: Redirects) -> Self

Whether to follow redirects. Default Redirects::Follow(10).

Source

pub fn on_redirect( self, handler: impl Fn(&Hop, RedirectReply) + Send + Sync + 'static, ) -> Self

Ask before following each redirect. Needs Capabilities::manual_redirects; where the platform follows redirects itself, requests from this client fail with HttpError::Unsupported.

Source

pub fn on_challenge( self, handler: impl Fn(&Challenge, ChallengeReply) + Send + Sync + 'static, ) -> Self

Answer authentication challenges. Without a handler a 401 or 407 is delivered as the response.

Source

pub fn trust(self, trust: Trust) -> Self

Public-key pins, checked on top of the platform’s evaluation.

Source

pub fn on_server_trust( self, handler: impl Fn(&ServerTrust, TrustReply) + Send + Sync + 'static, ) -> Self

Decide on servers the platform does not trust, or confirm the ones it does. Needs Capabilities::server_trust.

Source

pub fn identity(self, identity: Identity) -> Self

Present this identity when a server asks for a client certificate. Needs Capabilities::client_identity.

Source

pub fn cookies(self, cookies: Cookies) -> Self

Where to keep cookies. Default Cookies::default.

Source

pub fn cache(self, cache: Cache) -> Self

Whether to keep an HTTP cache. Default Cache::platform.

Source

pub fn header(self, name: &str, value: &str) -> Self

A header sent with every request that does not set it itself.

Source

pub fn user_agent(self, agent: &str) -> Self

The User-Agent sent with every request.

Source

pub fn max_per_host(self, limit: u32) -> Self

At most this many connections to one host, where the platform lets an app choose.

Source

pub fn wait_for_connectivity(self, wait: bool) -> Self

Wait for a usable network instead of failing at once, where the platform can (Capabilities::wait_for_connectivity).

Source

pub fn question_timeout(self, limit: Duration) -> Self

How long a handler may hold a question before its default answer is taken. Default two minutes.

Source

pub fn session(self, session: Session) -> Self

Route through an isolated session. By default clients follow Session::global(). An explicit transport overrides provider/interception selection for this client.

Source

pub fn transport(self, transport: impl Transport) -> Self

Perform exchanges through this transport instead of the platform’s: a test double, or an app’s own stack.

Source

pub fn build(self) -> Client

The client.

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

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.