Struct Connector

Source
pub struct Connector<T, U> { /* 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;
use scrappy_http::client::Connector;

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

Implementations§

Source§

impl Connector<(), ()>

Source

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

Source§

impl<T, U> Connector<T, U>

Source

pub fn connector<T1, U1>(self, connector: T1) -> Connector<T1, U1>
where U1: AsyncRead + AsyncWrite + Unpin + Debug, T1: Service<Request = TcpConnect<Uri>, Response = TcpConnection<Uri, U1>, Error = ConnectError> + Clone,

Use custom connector.

Source§

impl<T, U> Connector<T, U>
where U: AsyncRead + AsyncWrite + Unpin + Debug + 'static, T: Service<Request = Connect<Uri>, Response = Connection<Uri, U>, Error = ConnectError> + Clone + 'static,

Source

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

Connection timeout, i.e. max time to connect to remote host including dns name resolution. Set to 1 second by default.

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 finish( self, ) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError> + Clone

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, U> Freeze for Connector<T, U>
where T: Freeze,

§

impl<T, U> RefUnwindSafe for Connector<T, U>

§

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

§

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

§

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

§

impl<T, U> UnwindSafe for Connector<T, U>
where T: UnwindSafe, U: UnwindSafe,

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

Source§

type Output = T

Should always be Self
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.
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,