pub fn finish(
        self,
    ) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError>
                 + Clone {
        #[cfg(not(any(feature = "ssl", feature = "rust-tls")))]
        {
            let connector = TimeoutService::new(
                self.timeout,
                apply_fn(self.connector, |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .map(|stream| (stream.into_parts().0, Protocol::Http1)),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });

            connect_impl::InnerConnector {
                tcp_pool: ConnectionPool::new(
                    connector,
                    self.conn_lifetime,
                    self.conn_keep_alive,
                    None,
                    self.limit,
                ),
            }
        }
        #[cfg(any(feature = "ssl", feature = "rust-tls"))]
        {
            const H2: &[u8] = b"h2";
            #[cfg(feature = "ssl")]
            use actix_connect::ssl::OpensslConnector;
            #[cfg(feature = "rust-tls")]
            use actix_connect::ssl::RustlsConnector;
            use actix_service::boxed::service;
            #[cfg(feature = "rust-tls")]
            use rustls::Session;

            let ssl_service = TimeoutService::new(
                self.timeout,
                apply_fn(self.connector.clone(), |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .and_then(match self.ssl {
                    #[cfg(feature = "ssl")]
                    SslConnector::Openssl(ssl) => service(
                        OpensslConnector::service(ssl)
                            .map_err(ConnectError::from)
                            .map(|stream| {
                                let sock = stream.into_parts().0;
                                let h2 = sock
                                    .get_ref()
                                    .ssl()
                                    .selected_alpn_protocol()
                                    .map(|protos| protos.windows(2).any(|w| w == H2))
                                    .unwrap_or(false);
                                if h2 {
                                    (Box::new(sock) as Box<Io>, Protocol::Http2)
                                } else {
                                    (Box::new(sock) as Box<Io>, Protocol::Http1)
                                }
                            }),
                    ),
                    #[cfg(feature = "rust-tls")]
                    SslConnector::Rustls(ssl) => service(
                        RustlsConnector::service(ssl)
                            .map_err(ConnectError::from)
                            .map(|stream| {
                                let sock = stream.into_parts().0;
                                let h2 = sock
                                    .get_ref()
                                    .1
                                    .get_alpn_protocol()
                                    .map(|protos| protos.windows(2).any(|w| w == H2))
                                    .unwrap_or(false);
                                if h2 {
                                    (Box::new(sock) as Box<Io>, Protocol::Http2)
                                } else {
                                    (Box::new(sock) as Box<Io>, Protocol::Http1)
                                }
                            }),
                    ),
                }),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });

            let tcp_service = TimeoutService::new(
                self.timeout,
                apply_fn(self.connector.clone(), |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .map(|stream| (stream.into_parts().0, Protocol::Http1)),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });

            connect_impl::InnerConnector {
                tcp_pool: ConnectionPool::new(
                    tcp_service,
                    self.conn_lifetime,
                    self.conn_keep_alive,
                    None,
                    self.limit,
                ),
                ssl_pool: ConnectionPool::new(
                    ssl_service,
                    self.conn_lifetime,
                    self.conn_keep_alive,
                    Some(self.disconnect_timeout),
                    self.limit,
                ),
            }
        }
    }
/// Finish configuration process and create connector service.
/// The Connector builder always concludes by calling `finish()` last in
/// its combinator chain.
Finish configuration process and create connector service.
The Connector builder always concludes by calling `finish()` last in
its combinator chain.
Finish configuration process and create connector service . The Connector builder always concludes by calling ` finish () ` last in its combinator chain .
pub fn finish(
        self,
    ) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError>
                 + Clone {
        #[cfg(not(any(feature = "ssl", feature = "rust-tls")))]
        {
            let connector = TimeoutService::new(
                self.timeout,
                apply_fn(self.connector, |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .map(|stream| (stream.into_parts().0, Protocol::Http1)),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });
            connect_impl::InnerConnector {
                tcp_pool: ConnectionPool::new(
                    connector,
                    self.conn_lifetime,
                    self.conn_keep_alive,
                    None,
                    self.limit,
                ),
            }
        }
        #[cfg(any(feature = "ssl", feature = "rust-tls"))]
        {
            const H2: &[u8] = b"h2";
            #[cfg(feature = "ssl")]
            use actix_connect::ssl::OpensslConnector;
            #[cfg(feature = "rust-tls")]
            use actix_connect::ssl::RustlsConnector;
            use actix_service::boxed::service;
            #[cfg(feature = "rust-tls")]
            use rustls::Session;
            let ssl_service = TimeoutService::new(
                self.timeout,
                apply_fn(self.connector.clone(), |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .and_then(match self.ssl {
                    #[cfg(feature = "ssl")]
                    SslConnector::Openssl(ssl) => service(
                        OpensslConnector::service(ssl)
                            .map_err(ConnectError::from)
                            .map(|stream| {
                                let sock = stream.into_parts().0;
                                let h2 = sock
                                    .get_ref()
                                    .ssl()
                                    .selected_alpn_protocol()
                                    .map(|protos| protos.windows(2).any(|w| w == H2))
                                    .unwrap_or(false);
                                if h2 {
                                    (Box::new(sock) as Box<Io>, Protocol::Http2)
                                } else {
                                    (Box::new(sock) as Box<Io>, Protocol::Http1)
                                }
                            }),
                    ),
                    #[cfg(feature = "rust-tls")]
                    SslConnector::Rustls(ssl) => service(
                        RustlsConnector::service(ssl)
                            .map_err(ConnectError::from)
                            .map(|stream| {
                                let sock = stream.into_parts().0;
                                let h2 = sock
                                    .get_ref()
                                    .1
                                    .get_alpn_protocol()
                                    .map(|protos| protos.windows(2).any(|w| w == H2))
                                    .unwrap_or(false);
                                if h2 {
                                    (Box::new(sock) as Box<Io>, Protocol::Http2)
                                } else {
                                    (Box::new(sock) as Box<Io>, Protocol::Http1)
                                }
                            }),
                    ),
                }),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });
            let tcp_service = TimeoutService::new(
                self.timeout,
                apply_fn(self.connector.clone(), |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .map(|stream| (stream.into_parts().0, Protocol::Http1)),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });
            connect_impl::InnerConnector {
                tcp_pool: ConnectionPool::new(
                    tcp_service,
                    self.conn_lifetime,
                    self.conn_keep_alive,
                    None,
                    self.limit,
                ),
                ssl_pool: ConnectionPool::new(
                    ssl_service,
                    self.conn_lifetime,
                    self.conn_keep_alive,
                    Some(self.disconnect_timeout),
                    self.limit,
                ),
            }
        }
    }
pub fn finish ( self , ) -> impl Service < Request = Connect , Response = impl Connection , Error = ConnectError > + Clone { # [ cfg ( not ( any ( feature " " feature " " ) ) ) ] { let connector = TimeoutService :: new ( self . timeout , apply_fn ( self . connector , | msg : Connect , srv | { srv . call ( TcpConnect :: new ( msg . uri ) . set_addr ( msg . addr ) ) } ) . map_err ( ConnectError :: from ) . map ( | stream | ( stream . into_parts ( ) . 0 , Protocol :: Http1 ) ) , ) . map_err ( | e | match e { TimeoutError :: Service ( e ) => e , TimeoutError :: Timeout => ConnectError :: Timeout , } ) ; connect_impl :: InnerConnector { tcp_pool : ConnectionPool :: new ( connector , self . conn_lifetime , self . conn_keep_alive , None , self . limit , ) , } } # [ cfg ( any ( feature " " feature " " ) ) ] { const H2 : & [ u8 ] = b" " ; # [ cfg ( feature " " ) ] use actix_connect :: ssl :: OpensslConnector ; # [ cfg ( feature " " ) ] use actix_connect :: ssl :: RustlsConnector ; use actix_service :: boxed :: service ; # [ cfg ( feature " " ) ] use rustls :: Session ; let ssl_service = TimeoutService :: new ( self . timeout , apply_fn ( self . connector . clone ( ) , | msg : Connect , srv | { srv . call ( TcpConnect :: new ( msg . uri ) . set_addr ( msg . addr ) ) } ) . map_err ( ConnectError :: from ) . and_then ( match self . ssl { # [ cfg ( feature " " ) ] SslConnector :: Openssl ( ssl ) => service ( OpensslConnector :: service ( ssl ) . map_err ( ConnectError :: from ) . map ( | stream | { let sock = stream . into_parts ( ) . 0 ; let h2 = sock . get_ref ( ) . ssl ( ) . selected_alpn_protocol ( ) . map ( | protos | protos . windows ( 2 ) . any ( | w | w == H2 ) ) . unwrap_or ( false ) ; if h2 { ( Box :: new ( sock ) as Box < Io > , Protocol :: Http2 ) } else { ( Box :: new ( sock ) as Box < Io > , Protocol :: Http1 ) } } ) , ) , # [ cfg ( feature " " ) ] SslConnector :: Rustls ( ssl ) => service ( RustlsConnector :: service ( ssl ) . map_err ( ConnectError :: from ) . map ( | stream | { let sock = stream . into_parts ( ) . 0 ; let h2 = sock . get_ref ( ) . 1 . get_alpn_protocol ( ) . map ( | protos | protos . windows ( 2 ) . any ( | w | w == H2 ) ) . unwrap_or ( false ) ; if h2 { ( Box :: new ( sock ) as Box < Io > , Protocol :: Http2 ) } else { ( Box :: new ( sock ) as Box < Io > , Protocol :: Http1 ) } } ) , ) , } ) , ) . map_err ( | e | match e { TimeoutError :: Service ( e ) => e , TimeoutError :: Timeout => ConnectError :: Timeout , } ) ; let tcp_service = TimeoutService :: new ( self . timeout , apply_fn ( self . connector . clone ( ) , | msg : Connect , srv | { srv . call ( TcpConnect :: new ( msg . uri ) . set_addr ( msg . addr ) ) } ) . map_err ( ConnectError :: from ) . map ( | stream | ( stream . into_parts ( ) . 0 , Protocol :: Http1 ) ) , ) . map_err ( | e | match e { TimeoutError :: Service ( e ) => e , TimeoutError :: Timeout => ConnectError :: Timeout , } ) ; connect_impl :: InnerConnector { tcp_pool : ConnectionPool :: new ( tcp_service , self . conn_lifetime , self . conn_keep_alive , None , self . limit , ) , ssl_pool : ConnectionPool :: new ( ssl_service , self . conn_lifetime , self . conn_keep_alive , Some ( self . disconnect_timeout ) , self . limit , ) , } } }
Finish configuration process and create connector service.
Finish configuration process and create connector service .
self