@@ -8,17 +8,14 @@ use pin_project_lite::pin_project;
88#[ cfg( unix) ]
99use tokio:: net:: UnixStream ;
1010use tokio:: {
11- io:: { AsyncRead , AsyncWrite } ,
11+ io:: { AsyncRead , AsyncWrite , ReadBuf } ,
1212 net:: TcpStream ,
1313} ;
1414use tokio_boring2:: SslStream ;
1515
1616use super :: { AsyncConnWithInfo , TlsInfoFactory } ;
1717use crate :: {
18- core:: {
19- client:: connect:: { Connected , Connection } ,
20- rt:: { Read , ReadBufCursor , TokioIo , Write } ,
21- } ,
18+ core:: client:: connect:: { Connected , Connection } ,
2219 tls:: { MaybeHttpsStream , TlsInfo } ,
2320} ;
2421
@@ -43,7 +40,7 @@ pin_project! {
4340 /// It is mainly used internally to abstract over different connection types.
4441 pub struct TlsConn <T > {
4542 #[ pin]
46- inner: TokioIo < SslStream <T > >,
43+ inner: SslStream <T >,
4744 }
4845}
4946
@@ -65,48 +62,49 @@ impl Connection for Conn {
6562 }
6663}
6764
68- impl Read for Conn {
65+ impl AsyncRead for Conn {
66+ #[ inline]
6967 fn poll_read (
7068 self : Pin < & mut Self > ,
7169 cx : & mut Context ,
72- buf : ReadBufCursor < ' _ > ,
70+ buf : & mut ReadBuf < ' _ > ,
7371 ) -> Poll < io:: Result < ( ) > > {
74- let this = self . project ( ) ;
75- Read :: poll_read ( this. inner , cx, buf)
72+ AsyncRead :: poll_read ( self . project ( ) . inner , cx, buf)
7673 }
7774}
7875
79- impl Write for Conn {
76+ impl AsyncWrite for Conn {
77+ #[ inline]
8078 fn poll_write (
8179 self : Pin < & mut Self > ,
8280 cx : & mut Context ,
8381 buf : & [ u8 ] ,
8482 ) -> Poll < Result < usize , io:: Error > > {
85- let this = self . project ( ) ;
86- Write :: poll_write ( this. inner , cx, buf)
83+ AsyncWrite :: poll_write ( self . project ( ) . inner , cx, buf)
8784 }
8885
86+ #[ inline]
8987 fn poll_write_vectored (
9088 self : Pin < & mut Self > ,
9189 cx : & mut Context < ' _ > ,
9290 bufs : & [ IoSlice < ' _ > ] ,
9391 ) -> Poll < Result < usize , io:: Error > > {
94- let this = self . project ( ) ;
95- Write :: poll_write_vectored ( this. inner , cx, bufs)
92+ AsyncWrite :: poll_write_vectored ( self . project ( ) . inner , cx, bufs)
9693 }
9794
95+ #[ inline]
9896 fn is_write_vectored ( & self ) -> bool {
9997 self . inner . is_write_vectored ( )
10098 }
10199
100+ #[ inline]
102101 fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context ) -> Poll < Result < ( ) , io:: Error > > {
103- let this = self . project ( ) ;
104- Write :: poll_flush ( this. inner , cx)
102+ AsyncWrite :: poll_flush ( self . project ( ) . inner , cx)
105103 }
106104
105+ #[ inline]
107106 fn poll_shutdown ( self : Pin < & mut Self > , cx : & mut Context ) -> Poll < Result < ( ) , io:: Error > > {
108- let this = self . project ( ) ;
109- Write :: poll_shutdown ( this. inner , cx)
107+ AsyncWrite :: poll_shutdown ( self . project ( ) . inner , cx)
110108 }
111109}
112110
@@ -119,29 +117,27 @@ where
119117 /// Creates a new `TlsConn` wrapping the provided `SslStream`.
120118 #[ inline( always) ]
121119 pub fn new ( inner : SslStream < T > ) -> Self {
122- Self {
123- inner : TokioIo :: new ( inner) ,
124- }
120+ Self { inner }
125121 }
126122}
127123
128124// ===== impl TcpStream =====
129125
130126impl Connection for TlsConn < TcpStream > {
131127 fn connected ( & self ) -> Connected {
132- let connected = self . inner . inner ( ) . get_ref ( ) . connected ( ) ;
133- if self . inner . inner ( ) . ssl ( ) . selected_alpn_protocol ( ) == Some ( b"h2" ) {
128+ let connected = self . inner . get_ref ( ) . connected ( ) ;
129+ if self . inner . ssl ( ) . selected_alpn_protocol ( ) == Some ( b"h2" ) {
134130 connected. negotiated_h2 ( )
135131 } else {
136132 connected
137133 }
138134 }
139135}
140136
141- impl Connection for TlsConn < TokioIo < MaybeHttpsStream < TcpStream > > > {
137+ impl Connection for TlsConn < MaybeHttpsStream < TcpStream > > {
142138 fn connected ( & self ) -> Connected {
143- let connected = self . inner . inner ( ) . get_ref ( ) . connected ( ) ;
144- if self . inner . inner ( ) . ssl ( ) . selected_alpn_protocol ( ) == Some ( b"h2" ) {
139+ let connected = self . inner . get_ref ( ) . connected ( ) ;
140+ if self . inner . ssl ( ) . selected_alpn_protocol ( ) == Some ( b"h2" ) {
145141 connected. negotiated_h2 ( )
146142 } else {
147143 connected
@@ -154,8 +150,8 @@ impl Connection for TlsConn<TokioIo<MaybeHttpsStream<TcpStream>>> {
154150#[ cfg( unix) ]
155151impl Connection for TlsConn < UnixStream > {
156152 fn connected ( & self ) -> Connected {
157- let connected = self . inner . inner ( ) . get_ref ( ) . connected ( ) ;
158- if self . inner . inner ( ) . ssl ( ) . selected_alpn_protocol ( ) == Some ( b"h2" ) {
153+ let connected = self . inner . get_ref ( ) . connected ( ) ;
154+ if self . inner . ssl ( ) . selected_alpn_protocol ( ) == Some ( b"h2" ) {
159155 connected. negotiated_h2 ( )
160156 } else {
161157 connected
@@ -164,65 +160,66 @@ impl Connection for TlsConn<UnixStream> {
164160}
165161
166162#[ cfg( unix) ]
167- impl Connection for TlsConn < TokioIo < MaybeHttpsStream < UnixStream > > > {
163+ impl Connection for TlsConn < MaybeHttpsStream < UnixStream > > {
168164 fn connected ( & self ) -> Connected {
169- let connected = self . inner . inner ( ) . get_ref ( ) . connected ( ) ;
170- if self . inner . inner ( ) . ssl ( ) . selected_alpn_protocol ( ) == Some ( b"h2" ) {
165+ let connected = self . inner . get_ref ( ) . connected ( ) ;
166+ if self . inner . ssl ( ) . selected_alpn_protocol ( ) == Some ( b"h2" ) {
171167 connected. negotiated_h2 ( )
172168 } else {
173169 connected
174170 }
175171 }
176172}
177173
178- impl < T : AsyncRead + AsyncWrite + Unpin > Read for TlsConn < T > {
174+ impl < T : AsyncRead + AsyncWrite + Unpin > AsyncRead for TlsConn < T > {
175+ #[ inline]
179176 fn poll_read (
180177 self : Pin < & mut Self > ,
181178 cx : & mut Context ,
182- buf : ReadBufCursor < ' _ > ,
179+ buf : & mut ReadBuf < ' _ > ,
183180 ) -> Poll < tokio:: io:: Result < ( ) > > {
184- let this = self . project ( ) ;
185- Read :: poll_read ( this. inner , cx, buf)
181+ AsyncRead :: poll_read ( self . project ( ) . inner , cx, buf)
186182 }
187183}
188184
189- impl < T : AsyncRead + AsyncWrite + Unpin > Write for TlsConn < T > {
185+ impl < T : AsyncRead + AsyncWrite + Unpin > AsyncWrite for TlsConn < T > {
186+ #[ inline]
190187 fn poll_write (
191188 self : Pin < & mut Self > ,
192189 cx : & mut Context ,
193190 buf : & [ u8 ] ,
194191 ) -> Poll < Result < usize , tokio:: io:: Error > > {
195- let this = self . project ( ) ;
196- Write :: poll_write ( this. inner , cx, buf)
192+ AsyncWrite :: poll_write ( self . project ( ) . inner , cx, buf)
197193 }
198194
195+ #[ inline]
199196 fn poll_write_vectored (
200197 self : Pin < & mut Self > ,
201198 cx : & mut Context < ' _ > ,
202199 bufs : & [ IoSlice < ' _ > ] ,
203200 ) -> Poll < Result < usize , io:: Error > > {
204- let this = self . project ( ) ;
205- Write :: poll_write_vectored ( this. inner , cx, bufs)
201+ AsyncWrite :: poll_write_vectored ( self . project ( ) . inner , cx, bufs)
206202 }
207203
204+ #[ inline]
208205 fn is_write_vectored ( & self ) -> bool {
209206 self . inner . is_write_vectored ( )
210207 }
211208
209+ #[ inline]
212210 fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context ) -> Poll < Result < ( ) , tokio:: io:: Error > > {
213- let this = self . project ( ) ;
214- Write :: poll_flush ( this. inner , cx)
211+ AsyncWrite :: poll_flush ( self . project ( ) . inner , cx)
215212 }
216213
214+ #[ inline]
217215 fn poll_shutdown ( self : Pin < & mut Self > , cx : & mut Context ) -> Poll < Result < ( ) , tokio:: io:: Error > > {
218- let this = self . project ( ) ;
219- Write :: poll_shutdown ( this. inner , cx)
216+ AsyncWrite :: poll_shutdown ( self . project ( ) . inner , cx)
220217 }
221218}
222219
223220impl < T > TlsInfoFactory for TlsConn < T >
224221where
225- TokioIo < SslStream < T > > : TlsInfoFactory ,
222+ SslStream < T > : TlsInfoFactory ,
226223{
227224 fn tls_info ( & self ) -> Option < TlsInfo > {
228225 self . inner . tls_info ( )
0 commit comments