pub fn poll(&mut self) -> Result<bool, ChannelError> {
        let keep_going = true;
        let mut got_message = true;
        while got_message {
            match self.rx.try_recv() {
                Ok(c) => match c {
                    OckamCommand::Channel(ChannelCommand::Initiate(
                        mut route,
                        return_address,
                        key,
                    )) => {
                        if let AddressType::Channel = route.addresses[0].a_type {
                            if route.addresses[0].address.as_string() == *CHANNEL_ZERO {
                                route.addresses.remove(0);
                            }
                        }
                        self.init_key_ctx = key;
                        self.initiate_new_channel(route, return_address)?;
                    }
                    OckamCommand::Channel(ChannelCommand::Stop) => {
                        self.channels.clear();
                        break;
                    }
                    OckamCommand::Channel(ChannelCommand::SendMessage(m)) => {
                        self.handle_send(m)?;
                    }
                    OckamCommand::Channel(ChannelCommand::ReceiveMessage(m)) => {
                        self.handle_recv(m)?;
                    }
                    _ => return Err(ChannelErrorKind::InvalidParam(0).into()),
                },
                Err(_) => {
                    got_message = false;
                }
            }
        }
        Ok(keep_going)
    }
/// Check for work to be done and do it
Check for work to be done and do it
Check for work to be done and do it
pub fn poll(&mut self) -> Result<bool, ChannelError> {
        let keep_going = true;
        let mut got_message = true;
        while got_message {
            match self.rx.try_recv() {
                Ok(c) => match c {
                    OckamCommand::Channel(ChannelCommand::Initiate(
                        mut route,
                        return_address,
                        key,
                    )) => {
                        if let AddressType::Channel = route.addresses[0].a_type {
                            if route.addresses[0].address.as_string() == *CHANNEL_ZERO {
                                route.addresses.remove(0);
                            }
                        }
                        self.init_key_ctx = key;
                        self.initiate_new_channel(route, return_address)?;
                    }
                    OckamCommand::Channel(ChannelCommand::Stop) => {
                        self.channels.clear();
                        break;
                    }
                    OckamCommand::Channel(ChannelCommand::SendMessage(m)) => {
                        self.handle_send(m)?;
                    }
                    OckamCommand::Channel(ChannelCommand::ReceiveMessage(m)) => {
                        self.handle_recv(m)?;
                    }
                    _ => return Err(ChannelErrorKind::InvalidParam(0).into()),
                },
                Err(_) => {
                    got_message = false;
                }
            }
        }
        Ok(keep_going)
    }
pub fn poll ( & mut self ) -> Result < bool , ChannelError > { let keep_going = true ; let mut got_message = true ; while got_message { match self . rx . try_recv ( ) { Ok ( c ) => match c { OckamCommand :: Channel ( ChannelCommand :: Initiate ( mut route , return_address , key , ) ) => { if let AddressType :: Channel = route . addresses [ 0 ] . a_type { if route . addresses [ 0 ] . address . as_string ( ) == * CHANNEL_ZERO { route . addresses . remove ( 0 ) ; } } self . init_key_ctx = key ; self . initiate_new_channel ( route , return_address ) ? ; } OckamCommand :: Channel ( ChannelCommand :: Stop ) => { self . channels . clear ( ) ; break ; } OckamCommand :: Channel ( ChannelCommand :: SendMessage ( m ) ) => { self . handle_send ( m ) ? ; } OckamCommand :: Channel ( ChannelCommand :: ReceiveMessage ( m ) ) => { self . handle_recv ( m ) ? ; } _ => return Err ( ChannelErrorKind :: InvalidParam ( 0 ) . into ( ) ) , } , Err ( _ ) => { got_message = false ; } } } Ok ( keep_going ) }
Check for work to be done and do it
Check for work to be done and do it
&mut self