/// Proceed to the next stage of client <-> server hand shake
Proceed to the next stage of client <-> server hand shake
Proceed to the next stage of client < - > server hand shake
pub fn next_stage(&mut self, payload: Option<&[u8]>) -> Result<Status> {
        match self.state.take() {
            None => {
                self.state = Some(State::new());
                Ok(Status::Requesting(Request::Buffer(4)))
            }
            Some(state) => {
                if let Some(bytes) = payload {
                    let new_state = state.try_step(bytes)?;
                    let result = match new_state.clone() {
                        State::ParseSetup(ReadSetupMessage(len)) => Ok(Status::Requesting(Request::Buffer(len))),
                        State::MessageLen(MessageLen(len)) => Ok(Status::Requesting(Request::Buffer(len))),
                        State::SetupParsed(SetupParsed::Established(props)) => Ok(Status::Done(props)),
                        State::SetupParsed(SetupParsed::Secure) => Ok(Status::Requesting(Request::UpgradeToSsl)),
                        State::SetupParsed(SetupParsed::Cancel(conn_id, secret_key)) => {
                            Ok(Status::Cancel(conn_id, secret_key))
                        }
                    };
                    self.state = Some(new_state);
                    result
                } else {
                    self.state = Some(state.try_step(&[])?);
                    Ok(Status::Requesting(Request::Buffer(4)))
                }
            }
        }
    }
pub fn next_stage ( & mut self , payload : Option < & [ u8 ] > ) -> Result < Status > { match self . state . take ( ) { None => { self . state = Some ( State :: new ( ) ) ; Ok ( Status :: Requesting ( Request :: Buffer ( 4 ) ) ) } Some ( state ) => { if let Some ( bytes ) = payload { let new_state = state . try_step ( bytes ) ? ; let result = match new_state . clone ( ) { State :: ParseSetup ( ReadSetupMessage ( len ) ) => Ok ( Status :: Requesting ( Request :: Buffer ( len ) ) ) , State :: MessageLen ( MessageLen ( len ) ) => Ok ( Status :: Requesting ( Request :: Buffer ( len ) ) ) , State :: SetupParsed ( SetupParsed :: Established ( props ) ) => Ok ( Status :: Done ( props ) ) , State :: SetupParsed ( SetupParsed :: Secure ) => Ok ( Status :: Requesting ( Request :: UpgradeToSsl ) ) , State :: SetupParsed ( SetupParsed :: Cancel ( conn_id , secret_key ) ) => { Ok ( Status :: Cancel ( conn_id , secret_key ) ) } } ; self . state = Some ( new_state ) ; result } else { self . state = Some ( state . try_step ( & [ ] ) ? ) ; Ok ( Status :: Requesting ( Request :: Buffer ( 4 ) ) ) } } } }
Proceed to the next stage of client <-> server hand shake
Proceed to the next stage of client < - > server hand shake
&mut self
payload
Option<&[u8]>