ClientBuilder

Struct ClientBuilder 

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

A ClientBuilder can be used to create a Client with custom configuration.

Implementations§

Source§

impl ClientBuilder

Source

pub fn new() -> Self

Available on non-crate feature async only.

Constructs a new ClientBuilder.

This is the same as Client::builder().

Source

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

Available on non-crate feature async only.

Returns a Client that uses this ClientBuilder configuration.

§Errors

This method fails if TLS backend cannot be initialized, or the resolver cannot load the system configuration.

Source

pub fn user_agent<V>(self, value: V) -> ClientBuilder

Available on non-crate feature async only.

Sets the User-Agent header to be used by this client.

Source

pub fn default_headers(self, headers: HeaderMap) -> ClientBuilder

Available on non-crate feature async only.

Sets the default headers for every request

Source

pub fn timeout<T>(self, timeout: T) -> ClientBuilder
where T: Into<Option<Duration>>,

Available on non-crate feature async only.

Set a timeout for connect, read and write operations of a Client.

Default is 30 seconds.

Pass None to disable timeout.

Source

pub fn connect_timeout<T>(self, timeout: T) -> ClientBuilder
where T: Into<Option<Duration>>,

Available on non-crate feature async only.

Set a timeout for only the connect phase of a Client.

Default is None.

Trait Implementations§

Source§

impl Debug for ClientBuilder

Available on non-crate feature async only.
Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ClientBuilder

Available on non-crate feature async only.
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 = 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.