pub fn single_round<Obj: TryParse>(mut self) -> Result<RoundResult<Obj, Stream>> {
        trace!("Doing handshake round.");
        match self.state {
            HandshakeState::Reading(mut buf) => {
                let read = buf.read_from(&mut self.stream).no_block()?;
                match read {
                    Some(0) => Err(Error::Protocol(ProtocolError::HandshakeIncomplete)),
                    Some(_) => Ok(if let Some((size, obj)) = Obj::try_parse(Buf::chunk(&buf))? {
                        buf.advance(size);
                        RoundResult::StageFinished(StageResult::DoneReading {
                            result: obj,
                            stream: self.stream,
                            tail: buf.into_vec(),
                        })
                    } else {
                        RoundResult::Incomplete(HandshakeMachine {
                            state: HandshakeState::Reading(buf),
                            ..self
                        })
                    }),
                    None => Ok(RoundResult::WouldBlock(HandshakeMachine {
                        state: HandshakeState::Reading(buf),
                        ..self
                    })),
                }
            }
            HandshakeState::Writing(mut buf) => {
                assert!(buf.has_remaining());
                if let Some(size) = self.stream.write(Buf::chunk(&buf)).no_block()? {
                    assert!(size > 0);
                    buf.advance(size);
                    Ok(if buf.has_remaining() {
                        RoundResult::Incomplete(HandshakeMachine {
                            state: HandshakeState::Writing(buf),
                            ..self
                        })
                    } else {
                        RoundResult::StageFinished(StageResult::DoneWriting(self.stream))
                    })
                } else {
                    Ok(RoundResult::WouldBlock(HandshakeMachine {
                        state: HandshakeState::Writing(buf),
                        ..self
                    }))
                }
            }
        }
    }
/// Perform a single handshake round.
Perform a single handshake round.
Perform a single handshake round .
pub fn single_round<Obj: TryParse>(mut self) -> Result<RoundResult<Obj, Stream>> {
        trace!("Doing handshake round.");
        match self.state {
            HandshakeState::Reading(mut buf) => {
                let read = buf.read_from(&mut self.stream).no_block()?;
                match read {
                    Some(0) => Err(Error::Protocol(ProtocolError::HandshakeIncomplete)),
                    Some(_) => Ok(if let Some((size, obj)) = Obj::try_parse(Buf::chunk(&buf))? {
                        buf.advance(size);
                        RoundResult::StageFinished(StageResult::DoneReading {
                            result: obj,
                            stream: self.stream,
                            tail: buf.into_vec(),
                        })
                    } else {
                        RoundResult::Incomplete(HandshakeMachine {
                            state: HandshakeState::Reading(buf),
                            ..self
                        })
                    }),
                    None => Ok(RoundResult::WouldBlock(HandshakeMachine {
                        state: HandshakeState::Reading(buf),
                        ..self
                    })),
                }
            }
            HandshakeState::Writing(mut buf) => {
                assert!(buf.has_remaining());
                if let Some(size) = self.stream.write(Buf::chunk(&buf)).no_block()? {
                    assert!(size > 0);
                    buf.advance(size);
                    Ok(if buf.has_remaining() {
                        RoundResult::Incomplete(HandshakeMachine {
                            state: HandshakeState::Writing(buf),
                            ..self
                        })
                    } else {
                        RoundResult::StageFinished(StageResult::DoneWriting(self.stream))
                    })
                } else {
                    Ok(RoundResult::WouldBlock(HandshakeMachine {
                        state: HandshakeState::Writing(buf),
                        ..self
                    }))
                }
            }
        }
    }
pub fn single_round < Obj : TryParse > ( mut self ) -> Result < RoundResult < Obj , Stream > > { trace ! ( " " ) ; match self . state { HandshakeState :: Reading ( mut buf ) => { let read = buf . read_from ( & mut self . stream ) . no_block ( ) ? ; match read { Some ( 0 ) => Err ( Error :: Protocol ( ProtocolError :: HandshakeIncomplete ) ) , Some ( _ ) => Ok ( if let Some ( ( size , obj ) ) = Obj :: try_parse ( Buf :: chunk ( & buf ) ) ? { buf . advance ( size ) ; RoundResult :: StageFinished ( StageResult :: DoneReading { result : obj , stream : self . stream , tail : buf . into_vec ( ) , } ) } else { RoundResult :: Incomplete ( HandshakeMachine { state : HandshakeState :: Reading ( buf ) , .. self } ) } ) , None => Ok ( RoundResult :: WouldBlock ( HandshakeMachine { state : HandshakeState :: Reading ( buf ) , .. self } ) ) , } } HandshakeState :: Writing ( mut buf ) => { assert ! ( buf has_remaining ( ) ) ; if let Some ( size ) = self . stream . write ( Buf :: chunk ( & buf ) ) . no_block ( ) ? { assert ! ( size 0 ) ; buf . advance ( size ) ; Ok ( if buf . has_remaining ( ) { RoundResult :: Incomplete ( HandshakeMachine { state : HandshakeState :: Writing ( buf ) , .. self } ) } else { RoundResult :: StageFinished ( StageResult :: DoneWriting ( self . stream ) ) } ) } else { Ok ( RoundResult :: WouldBlock ( HandshakeMachine { state : HandshakeState :: Writing ( buf ) , .. self } ) ) } } } }
Perform a single handshake round.
Perform a single handshake round .
mut self
mut self