pub fn next_stage(&mut self, payload: Option<&[u8]>) -> Result<Status> {
        let payload = if let Some(payload) = payload { payload } else { &[] };
        let mut state = unsafe { MaybeUninit::zeroed().assume_init() };
        std::mem::swap(&mut state, &mut self.state);
        let (new_state, prev) = state.try_step(payload)?;
        self.state = new_state;
        match prev {
            State::Created(_) => Ok(Status::Requesting(1)),
            State::RequestingTag(_) => Ok(Status::Requesting(4)),
            State::Tag(Tag(tag)) => {
                self.tag = tag;
                Ok(Status::Requesting((Cursor::from(payload).read_i32()? - 4) as usize))
            }
            State::WaitingForPayload(_) => Ok(Status::Decoding),
            State::Payload(Payload(data)) => {
                let message = FrontendMessage::decode(self.tag, &data)?;
                Ok(Status::Done(message))
            }
        }
    }
/// Proceed to the next stage of decoding received message
Proceed to the next stage of decoding received message
Proceed to the next stage of decoding received message
pub fn next_stage(&mut self, payload: Option<&[u8]>) -> Result<Status> {
        let payload = if let Some(payload) = payload { payload } else { &[] };
        let mut state = unsafe { MaybeUninit::zeroed().assume_init() };
        std::mem::swap(&mut state, &mut self.state);
        let (new_state, prev) = state.try_step(payload)?;
        self.state = new_state;
        match prev {
            State::Created(_) => Ok(Status::Requesting(1)),
            State::RequestingTag(_) => Ok(Status::Requesting(4)),
            State::Tag(Tag(tag)) => {
                self.tag = tag;
                Ok(Status::Requesting((Cursor::from(payload).read_i32()? - 4) as usize))
            }
            State::WaitingForPayload(_) => Ok(Status::Decoding),
            State::Payload(Payload(data)) => {
                let message = FrontendMessage::decode(self.tag, &data)?;
                Ok(Status::Done(message))
            }
        }
    }
pub fn next_stage ( & mut self , payload : Option < & [ u8 ] > ) -> Result < Status > { let payload = if let Some ( payload ) = payload { payload } else { & [ ] } ; let mut state = unsafe { MaybeUninit :: zeroed ( ) . assume_init ( ) } ; std :: mem :: swap ( & mut state , & mut self . state ) ; let ( new_state , prev ) = state . try_step ( payload ) ? ; self . state = new_state ; match prev { State :: Created ( _ ) => Ok ( Status :: Requesting ( 1 ) ) , State :: RequestingTag ( _ ) => Ok ( Status :: Requesting ( 4 ) ) , State :: Tag ( Tag ( tag ) ) => { self . tag = tag ; Ok ( Status :: Requesting ( ( Cursor :: from ( payload ) . read_i32 ( ) ? - 4 ) as usize ) ) } State :: WaitingForPayload ( _ ) => Ok ( Status :: Decoding ) , State :: Payload ( Payload ( data ) ) => { let message = FrontendMessage :: decode ( self . tag , & data ) ? ; Ok ( Status :: Done ( message ) ) } } }
Proceed to the next stage of decoding received message
Proceed to the next stage of decoding received message
&mut self
payload
Option<&[u8]>
&mut self
payload
Option<&[u8]>