From 79a84be9a511557e75e0d71ab76fd1d046bac931 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Wed, 27 Jan 2021 23:04:36 -0800 Subject: [PATCH] use localboxfuture alias --- awc/src/connect.rs | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/awc/src/connect.rs b/awc/src/connect.rs index 5b1a0d90b..a9b7a8ab2 100644 --- a/awc/src/connect.rs +++ b/awc/src/connect.rs @@ -1,6 +1,5 @@ use std::{ fmt, - future::Future, io, net, pin::Pin, task::{Context, Poll}, @@ -14,34 +13,28 @@ use actix_http::{ RequestHead, RequestHeadType, ResponseHead, }; use actix_service::Service; +use futures_core::future::LocalBoxFuture; use crate::response::ClientResponse; pub(crate) struct ConnectorWrapper(pub T); +type TunnelResponse = (ResponseHead, Framed); + pub(crate) trait Connect { fn send_request( &mut self, head: RequestHeadType, body: Body, addr: Option, - ) -> Pin>>>; + ) -> LocalBoxFuture<'static, Result>; /// Send request, returns Response and Framed fn open_tunnel( &mut self, head: RequestHead, addr: Option, - ) -> Pin< - Box< - dyn Future< - Output = Result< - (ResponseHead, Framed), - SendRequestError, - >, - >, - >, - >; + ) -> LocalBoxFuture<'static, Result>; } impl Connect for ConnectorWrapper @@ -58,7 +51,7 @@ where head: RequestHeadType, body: Body, addr: Option, - ) -> Pin>>> { + ) -> LocalBoxFuture<'static, Result> { // connect to the host let fut = self.0.call(ClientConnect { uri: head.as_ref().uri.clone(), @@ -79,16 +72,7 @@ where &mut self, head: RequestHead, addr: Option, - ) -> Pin< - Box< - dyn Future< - Output = Result< - (ResponseHead, Framed), - SendRequestError, - >, - >, - >, - > { + ) -> LocalBoxFuture<'static, Result> { // connect to the host let fut = self.0.call(ClientConnect { uri: head.uri.clone(),