Skip to main content

Builder

Struct Builder 

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

Builds a partition-aware connection pool.

Implementations§

Source§

impl<Tls> Builder<Tls>

Source

pub fn idle_timeout(self, timeout: impl Into<Option<Duration>>) -> Self

Sets how long a reusable idle connection remains in the pool.

Passing None disables idle expiration. When unset, the pool uses a 90-second timeout.

Source

pub fn set_idle_timeout( &mut self, timeout: Option<Option<Duration>>, ) -> &mut Self

Mutably sets the idle timeout.

The outer None restores the default; Some(None) disables expiry.

Source

pub fn time_source(self, source: impl TimeSource + 'static) -> Self

Sets the clock used by pool maintenance and connection timing.

Source

pub fn set_time_source(&mut self, source: Option<SharedTimeSource>) -> &mut Self

Mutably sets the clock used by pool maintenance and connection timing.

Source

pub fn sleep_impl(self, sleep: impl AsyncSleep + 'static) -> Self

Sets the sleep implementation used by pool maintenance.

Source

pub fn set_sleep_impl(&mut self, sleep: Option<SharedAsyncSleep>) -> &mut Self

Mutably sets the sleep implementation used by pool maintenance.

Source

pub fn tcp_nodelay(self, enabled: bool) -> Self

Configures TCP_NODELAY for newly created sockets.

Source

pub fn set_tcp_nodelay(&mut self, enabled: bool) -> &mut Self

Mutably configures TCP_NODELAY.

Source

pub fn tcp_keepalive(self, time: impl Into<Option<Duration>>) -> Self

Configures TCP keepalive for newly created sockets.

Source

pub fn set_tcp_keepalive(&mut self, time: Option<Option<Duration>>) -> &mut Self

Mutably configures TCP keepalive.

Source

pub fn max_connections_per_host(self, limit: usize) -> Self

Bounds connection capacity for one origin across every pool partition.

An origin is a scheme, host, and port, so https://example.com and http://example.com are bounded separately, as is each non-default port. Establishing, idle, and active connections occupy capacity. Logical close normally returns capacity while accepted work drains. An HTTP/1 upgrade retains capacity until the caller releases upgraded I/O. This is not an idle-connection limit.

Source

pub fn set_max_connections_per_host( &mut self, limit: Option<usize>, ) -> &mut Self

Mutably sets the connection-capacity bound described by Builder::max_connections_per_host.

Source

pub fn connection_reuse_scope(self, scope: ConnectionReuseScope) -> Self

Selects which partitions may reuse each other’s connections.

Source

pub fn set_connection_reuse_scope( &mut self, scope: ConnectionReuseScope, ) -> &mut Self

Mutably selects the connection reuse scope.

Source

pub fn partitions(self, partitions: impl IntoIterator<Item = Partition>) -> Self

Declares the complete explicit partition set.

Source

pub fn set_partitions( &mut self, partitions: Option<Vec<Partition>>, ) -> &mut Self

Mutably declares or clears the explicit partition set.

Source

pub fn proxy_config(self, config: ProxyConfig) -> Self

Configures proxy selection for every connection established by this pool.

The configuration applies across every partition. Proxying is disabled unless this method is called.

Source

pub fn set_proxy_config(&mut self, config: Option<ProxyConfig>) -> &mut Self

Mutably configures pool-wide proxy selection.

Passing None disables proxying.

Source

pub fn dns_resolver(self, resolver: impl ResolveDns + 'static) -> Self

Configures the DNS resolver used by connections established by this pool.

The resolver applies across every partition. When unset, the client uses its default resolver, which currently delegates to the operating system.

Source

pub fn set_dns_resolver( &mut self, resolver: Option<SharedDnsResolver>, ) -> &mut Self

Mutably configures the pool-wide DNS resolver.

Passing None restores the client default.

Source

pub fn event_listener(self, listener: impl ConnectionEventListener) -> Self

Observes connection establishment and installed-lifetime transitions.

The listener applies to every partition. Each callback runs synchronously on the task that completed the transition and after pool locks are released. A listener must not block on work that requires progress from that same task.

Observation is disabled unless a listener is configured.

Source

pub fn set_event_listener( &mut self, listener: Option<SharedConnectionEventListener>, ) -> &mut Self

Mutably configures pool-wide connection lifecycle observation.

Passing None disables observation. The callback contract is the same as Builder::event_listener.

Source§

impl Builder<TlsUnset>

Source

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

Selects the TLS provider used by HTTPS pool connections.

Source§

impl Builder<TlsProviderSelected>

Source

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

Sets provider-specific TLS configuration for HTTPS connections.

Source

pub fn set_tls_context(&mut self, context: TlsContext) -> &mut Self

Mutably sets provider-specific TLS configuration.

Source

pub fn build_https(self) -> Result<ConnectionPool, BuildError>

Builds a pool whose connector performs TLS and ALPN negotiation.

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 Default for Builder<TlsUnset>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

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