Skip to main content

Builder

Struct Builder 

Source
pub struct Builder<Tls = TlsUnset> { /* private fields */ }
Expand description

Builder for a hyper-backed HttpClient implementation.

This builder can be used to customize the underlying TCP connector used, as well as hyper client configuration.

§Examples

Construct a Hyper client with the RusTLS TLS implementation. This can be useful when you want to share a Hyper connector between multiple generated Smithy clients.

Implementations§

Source§

impl Builder<TlsProviderSelected>

Source

pub fn build_https(self) -> SharedHttpClient

Create an HTTPS client with the selected TLS provider.

The trusted certificates will be loaded later when this becomes the selected HTTP client for a Smithy client.

Source

pub fn build_with_resolver( self, resolver: impl ResolveDns + Clone + 'static, ) -> SharedHttpClient

Create an HTTPS client using a custom DNS resolver

Source

pub fn tls_context(self, ctx: TlsContext) -> Self

Configure the TLS context

Source§

impl<Any> Builder<Any>

Source

pub fn pool_idle_timeout<D>(self, val: D) -> Self
where D: Into<Option<Duration>>,

Set an optional timeout for idle sockets being kept-alive.

Pass None to disable timeout.

Defaults to Hyper’s default timeout, which is currently 90 seconds - see hyper_util::client::legacy::Builder::pool_idle_timeout, but unlike that function, there is no need to call pool_timer yourself.

§Examples
use aws_smithy_http_client::{Builder, tls};
use std::time::Duration;

let client = Builder::new()
    .pool_idle_timeout(Duration::from_secs(30))
    .tls_provider(tls::Provider::Rustls(tls::rustls_provider::CryptoMode::AwsLc))
    .build_https();
Source

pub fn set_pool_idle_timeout( &mut self, val: Option<Option<Duration>>, ) -> &mut Self

Set an optional timeout for idle sockets being kept-alive.

Pass None to use Hyper’s default timeout, Some(None) to disable timeouts.

This is the mutable version of pool_idle_timeout.

§Examples
use std::time::Duration;
use aws_smithy_http_client::{Builder, tls};

let mut client = Builder::new();
client.set_pool_idle_timeout(Some(Some(Duration::from_secs(30))));
client
    .tls_provider(tls::Provider::Rustls(tls::rustls_provider::CryptoMode::AwsLc))
    .build_https();
Source

pub fn pool_max_idle_per_host(self, val: usize) -> Self

Sets the maximum number of idle pooled connections allowed per host.

Default is determined by the underlying hyper client, which is currently no limit (usize::MAX) - see hyper_util::client::legacy::Builder::pool_max_idle_per_host.

§Examples
use aws_smithy_http_client::{Builder, tls};

let client = Builder::new()
    .pool_max_idle_per_host(70)
    .tls_provider(tls::Provider::Rustls(tls::rustls_provider::CryptoMode::AwsLc))
    .build_https();
Source

pub fn set_pool_max_idle_per_host(&mut self, val: Option<usize>) -> &mut Self

Sets the maximum number of idle pooled connections allowed per host.

Pass None to use the hyper default (currently no limit, usize::MAX) - see hyper_util::client::legacy::Builder::pool_max_idle_per_host.

This is the mutable version of pool_max_idle_per_host.

Source§

impl Builder<TlsUnset>

Source

pub fn new() -> Self

Creates a new builder.

Source

pub fn tls_provider(self, provider: Provider) -> Builder<TlsProviderSelected>

Set the TLS implementation to use

Trait Implementations§

Source§

impl<Tls: Clone> Clone for Builder<Tls>

Source§

fn clone(&self) -> Builder<Tls>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Tls: Debug> Debug for Builder<Tls>

Source§

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

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

impl<Tls: Default> Default for Builder<Tls>

Source§

fn default() -> Builder<Tls>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Tls = TlsUnset> !RefUnwindSafe for Builder<Tls>

§

impl<Tls = TlsUnset> !UnwindSafe for Builder<Tls>

§

impl<Tls> Freeze for Builder<Tls>
where Tls: Freeze,

§

impl<Tls> Send for Builder<Tls>
where Tls: Send,

§

impl<Tls> Sync for Builder<Tls>
where Tls: Sync,

§

impl<Tls> Unpin for Builder<Tls>
where Tls: Unpin,

§

impl<Tls> UnsafeUnpin for Builder<Tls>
where Tls: UnsafeUnpin,

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.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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 = !

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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