/// Issues a connect call to the client policy layer and waits for the connection process to
/// complete.
Issues a connect call to the client policy layer and waits for the connection process to
complete.
Issues a connect call to the client policy layer and waits for the connection process to complete .
pub async fn handle_connect(
    client_controller: wlan_policy::ClientControllerProxy,
    mut server_stream: wlan_policy::ClientStateUpdatesRequestStream,
    mut network_id: wlan_policy::NetworkIdentifier,
) -> Result<(), Error> {
    let result = run_proxy_command(Box::pin(client_controller.connect(&mut network_id))).await?;
    handle_request_status(result)?;
    while let Some(update_request) = server_stream.try_next().await? {
        let update = update_request.into_on_client_state_update();
        let (update, responder) = match update {
            Some((update, responder)) => (update, responder),
            None => return Err(format_err!("Client provider produced invalid update.")),
        };
        let _ = responder.send();
        match update.state {
            Some(state) => {
                if state == wlan_policy::WlanClientState::ConnectionsDisabled {
                    return Err(format_err!("Connections disabled while trying to conncet."));
                }
            }
            None => continue,
        }
        let networks = match update.networks {
            Some(networks) => networks,
            None => continue,
        };
        for net_state in networks {
            if net_state.id.is_none() || net_state.state.is_none() {
                continue;
            }
            if net_state.id.unwrap().ssid == network_id.ssid {
                match net_state.state.unwrap() {
                    wlan_policy::ConnectionState::Failed => {
                        return Err(format_err!(
                            "Failed to connect with reason {:?}",
                            net_state.status
                        ));
                    }
                    wlan_policy::ConnectionState::Disconnected => {
                        return Err(format_err!("Disconnect with reason {:?}", net_state.status));
                    }
                    wlan_policy::ConnectionState::Connecting => continue,
                    wlan_policy::ConnectionState::Connected => return Ok(()),
                }
            }
        }
    }
    Err(format_err!("Status stream terminated before connection could be verified."))
}
pub async fn handle_connect ( client_controller : wlan_policy :: ClientControllerProxy , mut server_stream : wlan_policy :: ClientStateUpdatesRequestStream , mut network_id : wlan_policy :: NetworkIdentifier , ) -> Result < ( ) , Error > { let result = run_proxy_command ( Box :: pin ( client_controller . connect ( & mut network_id ) ) ) . await ? ; handle_request_status ( result ) ? ; while let Some ( update_request ) = server_stream . try_next ( ) . await ? { let update = update_request . into_on_client_state_update ( ) ; let ( update , responder ) = match update { Some ( ( update , responder ) ) => ( update , responder ) , None => return Err ( format_err ! ( " " ) ) , } ; let _ = responder . send ( ) ; match update . state { Some ( state ) => { if state == wlan_policy :: WlanClientState :: ConnectionsDisabled { return Err ( format_err ! ( " " ) ) ; } } None => continue , } let networks = match update . networks { Some ( networks ) => networks , None => continue , } ; for net_state in networks { if net_state . id . is_none ( ) || net_state . state . is_none ( ) { continue ; } if net_state . id . unwrap ( ) . ssid == network_id . ssid { match net_state . state . unwrap ( ) { wlan_policy :: ConnectionState :: Failed => { return Err ( format_err ! ( " " net_state status ) ) ; } wlan_policy :: ConnectionState :: Disconnected => { return Err ( format_err ! ( " " net_state status ) ) ; } wlan_policy :: ConnectionState :: Connecting => continue , wlan_policy :: ConnectionState :: Connected => return Ok ( ( ) ) , } } } } Err ( format_err ! ( " " ) ) }
Issues a connect call to the client policy layer and waits for the connection process to
complete.
Issues a connect call to the client policy layer and waits for the connection process to complete .
client_controller
wlan_policy::ClientControllerProxy
server_stream
wlan_policy::ClientStateUpdatesRequestStream
network_id
wlan_policy::NetworkIdentifier