pub struct ClientBuilder { /* private fields */ }Expand description
A ClientBuilder can be used to create a Client with custom configuration applied consistently
and state tracked across subsequent requests.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn with_fronting(self, policy: Option<FrontPolicy>) -> Self
pub fn with_fronting(self, policy: Option<FrontPolicy>) -> Self
Enable and configure request tunneling for API requests. If no front policy is provided the shared fronting policy will be used.
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn dns_resolver<R: Resolve + 'static>(self, resolver: Arc<R>) -> Self
pub fn dns_resolver<R: Resolve + 'static>(self, resolver: Arc<R>) -> Self
Override the DNS resolver implementation used by the underlying http client.
This forces the use of an independent request executor (via Self::non_shared).
Sourcepub fn no_hickory_dns(self) -> Self
pub fn no_hickory_dns(self) -> Self
Override the DNS resolver implementation used by the underlying http client. If
Self::dns_resolver is called directly that will take priority over this, there is no
need to call both.
This forces the use of an independent request executor (via Self::non_shared).
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new<U>(url: U) -> Result<Self, HttpClientError>where
U: IntoUrl,
pub fn new<U>(url: U) -> Result<Self, HttpClientError>where
U: IntoUrl,
Constructs a new ClientBuilder.
This is the same as Client::builder().
Sourcepub fn new_with_urls(urls: Vec<Url>) -> Result<Self, HttpClientError>
pub fn new_with_urls(urls: Vec<Url>) -> Result<Self, HttpClientError>
Constructs a new http ClientBuilder from a valid url.
Configure use of an independent HTTP request executor. This prevents use of beneficial features like connection pooling under the hood.
Sourcepub fn add_url(self, url: Url) -> Self
pub fn add_url(self, url: Url) -> Self
Add an additional URL to the set usable by this constructed Client
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Enables a total request timeout other than the default.
The timeout is applied from when the request starts connecting until the response body has finished. Also considered a total deadline.
Default is DEFAULT_TIMEOUT.
Sourcepub fn with_retries(self, retry_limit: usize) -> Self
pub fn with_retries(self, retry_limit: usize) -> Self
Sets the maximum number of retries for a request. This defaults to 0, indicating no retries.
Note that setting a retry limit of 3 (for example) will result in 4 attempts to send the request in the case that all are unsuccessful.
If multiple urls (or fronting configurations if enabled) are available, retried requests will be sent to the next URL in the list.
Sourcepub fn with_reqwest_builder(self, reqwest_builder: ClientBuilder) -> Self
pub fn with_reqwest_builder(self, reqwest_builder: ClientBuilder) -> Self
Provide a pre-configured reqwest::ClientBuilder
Sourcepub fn with_user_agent<V>(self, value: V) -> Self
pub fn with_user_agent<V>(self, value: V) -> Self
Sets the User-Agent header to be used by this client.
Sourcepub fn with_serialization(self, format: SerializationFormat) -> Self
pub fn with_serialization(self, format: SerializationFormat) -> Self
Set the serialization format for API requests and responses
Sourcepub fn with_bincode(self) -> Self
pub fn with_bincode(self) -> Self
Configure the client to use bincode serialization
Sourcepub fn build(self) -> Result<Client, HttpClientError>
pub fn build(self) -> Result<Client, HttpClientError>
Returns a Client that uses this ClientBuilder configuration.
Auto Trait Implementations§
impl !Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin for ClientBuilder
impl !UnwindSafe for ClientBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more