/// Waiting Google IoT specific subscriptions
///
/// Google cloud has set of default subscriptions for receiving commands and configurations per
/// the framework.
///
/// # Example
/// ```
///    let packet_result = gcp_mqtt.wait_channels().or(async {
///        Timer::after(Duration::from_secs(timeout)).await;
///        Err(GcpIoTError::WaitTimeout)
///    }).await;
///
///    match packet_result {
///        Ok(ChannelData::Config(packet)) => {
///            // This is text of base64 so it is save to cast this to string
///            info!("Config packet {:?}", from_utf8(&packet).unwrap());
///        },
///        Ok(ChannelData::Command(packet)) => {
///            info!("Command packet {:?}", packet);
///        },
///        Err(GcpIoTError::WaitTimeout) => {
///            info!("Sending state information");
///            gcp_mqtt.set_device_state(&String::from("state")).await.unwrap();
///            Timer::after(Duration::from_secs(1)).await;
///            gcp_mqtt.connect().await.expect("Re-connect failed!");
///            info!("Reconnect succeeded");
///        },
///        Err(_) => {
///            warn!("Test receive loop terminated");
///            break;
///        }
///    }
/// ```
Waiting Google IoT specific subscriptions
Google cloud has set of default subscriptions for receiving commands and configurations per
the framework.
Waiting Google IoT specific subscriptions Google cloud has set of default subscriptions for receiving commands and configurations per the framework .
pub async fn wait_channels(&self) -> Result<ChannelData, GcpIoTError> {
        let packet: Result<ChannelData, GcpIoTError> = (async {
            let config_data = self.config.recv().await?;
            Ok(ChannelData::Config(config_data))
        })
        .or(async {
            let command_data = self.command.recv().await?;
            Ok(ChannelData::Command(command_data))
        })
        .await;
        packet
    }
pub async fn wait_channels ( & self ) -> Result < ChannelData , GcpIoTError > { let packet : Result < ChannelData , GcpIoTError > = ( async { let config_data = self . config . recv ( ) . await ? ; Ok ( ChannelData :: Config ( config_data ) ) } ) . or ( async { let command_data = self . command . recv ( ) . await ? ; Ok ( ChannelData :: Command ( command_data ) ) } ) . await ; packet }
Waiting Google IoT specific subscriptions
Google cloud has set of default subscriptions for receiving commands and configurations per
the framework.
Waiting Google IoT specific subscriptions Google cloud has set of default subscriptions for receiving commands and configurations per the framework .
&self
example
```
let packet_result = gcp_mqtt.wait_channels().or(async {
Timer::after(Duration::from_secs(timeout)).await;
Err(GcpIoTError::WaitTimeout)
}).await.

match packet_result {
Ok(ChannelData::Config(packet)) => {
This is text of base64 so it is save to cast this to string
info!("Config packet {:?}", from_utf8(&packet).unwrap());
},
Ok(ChannelData::Command(packet)) => {
info!("Command packet {:?}", packet);
},
Err(GcpIoTError::WaitTimeout) => {
info!("Sending state information");
gcp_mqtt.set_device_state(&String::from("state")).await.unwrap();
Timer::after(Duration::from_secs(1)).await;
gcp_mqtt.connect().await.expect("Re-connect failed!");
info!("Reconnect succeeded");
},
Err(_) => {
warn!("Test receive loop terminated");
break;
}
}
```
` ` ` let packet_result = gcp_mqtt . wait_channels () . or ( async { Timer :: after ( Duration :: from_secs ( timeout )) . await ; Err ( GcpIoTError :: WaitTimeout ) } ) . await . match packet_result { Ok ( ChannelData :: Config ( packet )) = > { This is text of base64 so it is save to cast this to string info! ( " Config packet { : ? } " from_utf8 ( &packet ) . unwrap () ) ; } Ok ( ChannelData :: Command ( packet )) = > { info! ( " Command packet { : ? } " packet ) ; } Err ( GcpIoTError :: WaitTimeout ) = > { info! ( " Sending state information " ) ; gcp_mqtt . set_device_state ( &String :: from ( " state " )) . await . unwrap () ; Timer :: after ( Duration :: from_secs ( 1 )) . await ; gcp_mqtt . connect () . await . expect ( " Re - connect failed! " ) ; info! ( " Reconnect succeeded " ) ; } Err ( _ ) = > { warn! ( " Test receive loop terminated " ) ; break ; } } ` ` `