Struct awc::Connector

source ·
pub struct Connector<T> { /* private fields */ }
Expand description

Manages HTTP client network connectivity.

The Connector type uses a builder-like combinator pattern for service construction that finishes by calling the .finish() method.

use std::time::Duration;

let connector = awc::Connector::new()
     .timeout(Duration::from_secs(5))
     .finish();

Implementations§

source§

impl Connector<()>

source

pub fn new( ) -> Connector<impl Service<ConnectInfo<Uri>, Response = TcpConnection<Uri, TcpStream>, Error = ConnectError> + Clone>

source§

impl<S> Connector<S>

source

pub fn connector<S1, Io1>(self, connector: S1) -> Connector<S1>
where Io1: ActixStream + Debug + 'static, S1: Service<ConnectInfo<Uri>, Response = TcpConnection<Uri, Io1>, Error = TcpConnectError> + Clone,

Sets custom connector.

source§

impl<S, IO> Connector<S>
where IO: ActixStream + Debug + 'static, S: Service<ConnectInfo<Uri>, Response = Connection<Uri, IO>, Error = ConnectError> + Clone + 'static,

source

pub fn timeout(self, timeout: Duration) -> Self

Sets TCP connection timeout.

This is the max time allowed to connect to remote host, including DNS name resolution.

By default, the timeout is 5 seconds.

source

pub fn handshake_timeout(self, timeout: Duration) -> Self

Sets TLS handshake timeout.

This is the max time allowed to perform the TLS handshake with remote host after TCP connection is established.

By default, the timeout is 5 seconds.

source

pub fn openssl(self, connector: SslConnector) -> Self

Available on crate feature openssl only.

Sets custom OpenSSL SslConnector instance.

source

pub fn rustls(self, connector: Arc<ClientConfig>) -> Self

Available on crate feature rustls-0_20 only.

Sets custom Rustls v0.20 ClientConfig instance.

source

pub fn rustls_021(self, connector: Arc<ClientConfig>) -> Self

Available on crate feature rustls-0_21 only.

Sets custom Rustls v0.21 ClientConfig instance.

source

pub fn rustls_0_22(self, connector: Arc<ClientConfig>) -> Self

Available on crate features rustls-0_22-webpki-roots or rustls-0_22-native-roots only.

Sets custom Rustls v0.22 ClientConfig instance.

source

pub fn max_http_version(self, val: Version) -> Self

Sets maximum supported HTTP major version.

Supported versions are HTTP/1.1 and HTTP/2.

source

pub fn initial_window_size(self, size: u32) -> Self

Sets the initial window size (in bytes) for HTTP/2 stream-level flow control for received data.

The default value is 65,535 and is good for APIs, but not for big objects.

source

pub fn initial_connection_window_size(self, size: u32) -> Self

Sets the initial window size (in bytes) for HTTP/2 connection-level flow control for received data.

The default value is 65,535 and is good for APIs, but not for big objects.

source

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

Set total number of simultaneous connections per type of scheme.

If limit is 0, the connector has no limit.

The default limit size is 100.

source

pub fn conn_keep_alive(self, dur: Duration) -> Self

Set keep-alive period for opened connection.

Keep-alive period is the period between connection usage. If the delay between repeated usages of the same connection exceeds this period, the connection is closed. Default keep-alive period is 15 seconds.

source

pub fn conn_lifetime(self, dur: Duration) -> Self

Set max lifetime period for connection.

Connection lifetime is max lifetime of any opened connection until it is closed regardless of keep-alive period. Default lifetime period is 75 seconds.

source

pub fn disconnect_timeout(self, dur: Duration) -> Self

Set server connection disconnect timeout in milliseconds.

Defines a timeout for disconnect connection. If a disconnect procedure does not complete within this time, the socket get dropped. This timeout affects only secure connections.

To disable timeout set value to 0.

By default disconnect timeout is set to 3000 milliseconds.

source

pub fn local_address(self, addr: IpAddr) -> Self

Set local IP Address the connector would use for establishing connection.

source

pub fn finish( self ) -> ConnectorServicePriv<TcpConnectorService<TcpConnectorInnerService<S>>, Rc<dyn Service<Connect, Response = (Box<dyn ConnectionIo>, Protocol), Error = ConnectError, Future = LocalBoxFuture<'static, Result<(Box<dyn ConnectionIo>, Protocol), ConnectError>>>>, IO, Box<dyn ConnectionIo>>

Finish configuration process and create connector service.

The Connector builder always concludes by calling finish() last in its combinator chain.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Connector<T>

§

impl<T> Send for Connector<T>
where T: Send,

§

impl<T> Sync for Connector<T>
where T: Sync,

§

impl<T> Unpin for Connector<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Connector<T>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more