@ -2,7 +2,6 @@ use crate::compat::{AllowStd, SetWaker};
use crate ::WebSocketStream ;
use futures ::io ::{ AsyncRead , AsyncWrite } ;
use log ::* ;
use pin_project ::pin_project ;
use std ::future ::Future ;
use std ::io ::{ Read , Write } ;
use std ::pin ::Pin ;
@ -51,7 +50,6 @@ where
}
}
#[ pin_project ]
struct MidHandshake < Role : HandshakeRole > ( Option < WsHandshake < Role > > ) ;
enum StartedHandshake < Role : HandshakeRole > {
@ -68,7 +66,7 @@ struct StartedHandshakeFutureInner<F, S> {
async fn handshake < Role , F , S > ( stream : S , f : F ) -> Result < Role ::FinalResult , Error < Role > >
where
Role : HandshakeRole + Unpin ,
Role ::InternalStream : SetWaker ,
Role ::InternalStream : SetWaker + Unpin ,
F : FnOnce ( AllowStd < S > ) -> Result < Role ::FinalResult , Error < Role > > + Unpin ,
S : AsyncRead + AsyncWrite + Unpin ,
{
@ -145,13 +143,12 @@ where
impl < Role > Future for MidHandshake < Role >
where
Role : HandshakeRole + Unpin ,
Role ::InternalStream : SetWaker ,
Role ::InternalStream : SetWaker + Unpin ,
{
type Output = Result < Role ::FinalResult , Error < Role > > ;
fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self ::Output > {
let this = self . project ( ) ;
let mut s = this . 0. take ( ) . expect ( "future polled after completion" ) ;
fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self ::Output > {
let mut s = self . as_mut ( ) . 0. take ( ) . expect ( "future polled after completion" ) ;
let machine = s . get_mut ( ) ;
trace ! ( "Setting context in handshake" ) ;
@ -161,7 +158,7 @@ where
Ok ( stream ) = > Poll ::Ready ( Ok ( stream ) ) ,
Err ( Error ::Failure ( e ) ) = > Poll ::Ready ( Err ( Error ::Failure ( e ) ) ) ,
Err ( Error ::Interrupted ( mid ) ) = > {
* this . 0 = Some ( mid ) ;
self . 0 = Some ( mid ) ;
Poll ::Pending
}
}