9898 S : AsyncRead + AsyncWrite + Unpin ,
9999{
100100 Raw ( S ) ,
101- Tls ( TlsStream < S > ) ,
101+ Tls ( Box < TlsStream < S > > ) ,
102102 Upgrading ,
103103}
104104
@@ -135,24 +135,24 @@ where
135135 . map_err ( |err| Error :: Tls ( err. into ( ) ) ) ?
136136 . to_owned ( ) ;
137137
138- * self = MaybeTlsStream :: Tls ( connector. connect ( host, stream) . await ?) ;
138+ * self = MaybeTlsStream :: Tls ( Box :: new ( connector. connect ( host, stream) . await ?) ) ;
139139
140140 Ok ( ( ) )
141141 }
142142
143143 pub fn downgrade ( & mut self ) -> Result < ( ) , Error > {
144144 match replace ( self , MaybeTlsStream :: Upgrading ) {
145- MaybeTlsStream :: Tls ( stream ) => {
145+ MaybeTlsStream :: Tls ( mut boxed_stream ) => {
146146 #[ cfg( feature = "_tls-rustls" ) ]
147147 {
148- let raw = stream . into_inner ( ) . 0 ;
148+ let raw = boxed_stream . into_inner ( ) . 0 ;
149149 * self = MaybeTlsStream :: Raw ( raw) ;
150150 Ok ( ( ) )
151151 }
152152
153153 #[ cfg( feature = "_tls-native-tls" ) ]
154154 {
155- let _ = stream ; // Use the variable to avoid warning
155+ let _ = boxed_stream ; // Use the variable to avoid warning
156156 return Err ( Error :: tls ( "No way to downgrade a native-tls stream, use rustls instead, or never disable tls" ) ) ;
157157 }
158158 }
@@ -216,7 +216,7 @@ where
216216 ) -> Poll < io:: Result < super :: PollReadOut > > {
217217 match & mut * self {
218218 MaybeTlsStream :: Raw ( s) => Pin :: new ( s) . poll_read ( cx, buf) ,
219- MaybeTlsStream :: Tls ( s) => Pin :: new ( s) . poll_read ( cx, buf) ,
219+ MaybeTlsStream :: Tls ( s) => Pin :: new ( & mut * * s) . poll_read ( cx, buf) ,
220220
221221 MaybeTlsStream :: Upgrading => Poll :: Ready ( Err ( io:: ErrorKind :: ConnectionAborted . into ( ) ) ) ,
222222 }
@@ -234,7 +234,7 @@ where
234234 ) -> Poll < io:: Result < usize > > {
235235 match & mut * self {
236236 MaybeTlsStream :: Raw ( s) => Pin :: new ( s) . poll_write ( cx, buf) ,
237- MaybeTlsStream :: Tls ( s) => Pin :: new ( s) . poll_write ( cx, buf) ,
237+ MaybeTlsStream :: Tls ( s) => Pin :: new ( & mut * * s) . poll_write ( cx, buf) ,
238238
239239 MaybeTlsStream :: Upgrading => Poll :: Ready ( Err ( io:: ErrorKind :: ConnectionAborted . into ( ) ) ) ,
240240 }
@@ -243,7 +243,7 @@ where
243243 fn poll_flush ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
244244 match & mut * self {
245245 MaybeTlsStream :: Raw ( s) => Pin :: new ( s) . poll_flush ( cx) ,
246- MaybeTlsStream :: Tls ( s) => Pin :: new ( s) . poll_flush ( cx) ,
246+ MaybeTlsStream :: Tls ( s) => Pin :: new ( & mut * * s) . poll_flush ( cx) ,
247247
248248 MaybeTlsStream :: Upgrading => Poll :: Ready ( Err ( io:: ErrorKind :: ConnectionAborted . into ( ) ) ) ,
249249 }
@@ -253,7 +253,7 @@ where
253253 fn poll_shutdown ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
254254 match & mut * self {
255255 MaybeTlsStream :: Raw ( s) => Pin :: new ( s) . poll_shutdown ( cx) ,
256- MaybeTlsStream :: Tls ( s) => Pin :: new ( s) . poll_shutdown ( cx) ,
256+ MaybeTlsStream :: Tls ( s) => Pin :: new ( & mut * * s) . poll_shutdown ( cx) ,
257257
258258 MaybeTlsStream :: Upgrading => Poll :: Ready ( Err ( io:: ErrorKind :: ConnectionAborted . into ( ) ) ) ,
259259 }
@@ -263,7 +263,7 @@ where
263263 fn poll_close ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
264264 match & mut * self {
265265 MaybeTlsStream :: Raw ( s) => Pin :: new ( s) . poll_close ( cx) ,
266- MaybeTlsStream :: Tls ( s) => Pin :: new ( s) . poll_close ( cx) ,
266+ MaybeTlsStream :: Tls ( s) => Pin :: new ( & mut * * s) . poll_close ( cx) ,
267267
268268 MaybeTlsStream :: Upgrading => Poll :: Ready ( Err ( io:: ErrorKind :: ConnectionAborted . into ( ) ) ) ,
269269 }
0 commit comments