async fn handle_client_requests(
    client: ClientPtr,
    internal_msg_sink: InternalMsgSink,
    saved_networks: SavedNetworksPtr,
    requests: ClientRequests,
) -> Result<(), fidl::Error> {
    let mut request_stream = requests.into_stream()?;
    while let Some(request) = request_stream.try_next().await? {
        match request {
            fidl_policy::ClientControllerRequest::Connect { id, responder, .. } => {
                match handle_client_request_connect(
                    Arc::clone(&client),
                    Arc::clone(&saved_networks),
                    &id,
                )
                .await
                {
                    Ok((cred, txn)) => {
                        responder.send(fidl_common::RequestStatus::Acknowledged)?;
                        // TODO(hahnr): Send connecting update.
                        let _ignored = internal_msg_sink
                            .unbounded_send(InternalMsg::NewPendingConnectRequest(id, cred, txn));
                    }
                    Err(error) => {
                        error!("error while connection attempt: {}", error.cause);
                        responder.send(error.status)?;
                    }
                }
            }
            fidl_policy::ClientControllerRequest::StartClientConnections { responder } => {
                let status = handle_client_request_start_connections();
                responder.send(status)?;
            }
            fidl_policy::ClientControllerRequest::StopClientConnections { responder } => {
                let status = handle_client_request_stop_connections();
                responder.send(status)?;
            }
            fidl_policy::ClientControllerRequest::ScanForNetworks { iterator, .. } => {
                handle_client_request_scan(iterator).await?;
            }
            fidl_policy::ClientControllerRequest::SaveNetwork { config, responder } => {
                // If there is an error saving the network, log it and convert to a FIDL value.
                let mut response =
                    handle_client_request_save_network(Arc::clone(&saved_networks), config)
                        .map_err(|e| {
                            error!("Failed to save network: {:?}", e);
                            fidl_policy::NetworkConfigChangeError::from(e)
                        });
                responder.send(&mut response)?;
            }
            fidl_policy::ClientControllerRequest::RemoveNetwork { config, responder } => {
                let mut err =
                    handle_client_request_remove_network(Arc::clone(&saved_networks), config)
                        .map_err(|_| SaveError::GeneralError);
                responder.send(&mut err)?;
            }
            fidl_policy::ClientControllerRequest::GetSavedNetworks { iterator, .. } => {
                handle_client_request_get_networks(Arc::clone(&saved_networks), iterator).await?;
            }
        }
    }
    Ok(())
}
/// Handles all incoming requests from a ClientController.
Handles all incoming requests from a ClientController.
Handles all incoming requests from a ClientController .
async fn handle_client_requests(
    client: ClientPtr,
    internal_msg_sink: InternalMsgSink,
    saved_networks: SavedNetworksPtr,
    requests: ClientRequests,
) -> Result<(), fidl::Error> {
    let mut request_stream = requests.into_stream()?;
    while let Some(request) = request_stream.try_next().await? {
        match request {
            fidl_policy::ClientControllerRequest::Connect { id, responder, .. } => {
                match handle_client_request_connect(
                    Arc::clone(&client),
                    Arc::clone(&saved_networks),
                    &id,
                )
                .await
                {
                    Ok((cred, txn)) => {
                        responder.send(fidl_common::RequestStatus::Acknowledged)?;
                        // TODO(hahnr): Send connecting update.
                        let _ignored = internal_msg_sink
                            .unbounded_send(InternalMsg::NewPendingConnectRequest(id, cred, txn));
                    }
                    Err(error) => {
                        error!("error while connection attempt: {}", error.cause);
                        responder.send(error.status)?;
                    }
                }
            }
            fidl_policy::ClientControllerRequest::StartClientConnections { responder } => {
                let status = handle_client_request_start_connections();
                responder.send(status)?;
            }
            fidl_policy::ClientControllerRequest::StopClientConnections { responder } => {
                let status = handle_client_request_stop_connections();
                responder.send(status)?;
            }
            fidl_policy::ClientControllerRequest::ScanForNetworks { iterator, .. } => {
                handle_client_request_scan(iterator).await?;
            }
            fidl_policy::ClientControllerRequest::SaveNetwork { config, responder } => {
                // If there is an error saving the network, log it and convert to a FIDL value.
                let mut response =
                    handle_client_request_save_network(Arc::clone(&saved_networks), config)
                        .map_err(|e| {
                            error!("Failed to save network: {:?}", e);
                            fidl_policy::NetworkConfigChangeError::from(e)
                        });
                responder.send(&mut response)?;
            }
            fidl_policy::ClientControllerRequest::RemoveNetwork { config, responder } => {
                let mut err =
                    handle_client_request_remove_network(Arc::clone(&saved_networks), config)
                        .map_err(|_| SaveError::GeneralError);
                responder.send(&mut err)?;
            }
            fidl_policy::ClientControllerRequest::GetSavedNetworks { iterator, .. } => {
                handle_client_request_get_networks(Arc::clone(&saved_networks), iterator).await?;
            }
        }
    }
    Ok(())
}
async fn handle_client_requests ( client : ClientPtr , internal_msg_sink : InternalMsgSink , saved_networks : SavedNetworksPtr , requests : ClientRequests , ) -> Result < ( ) , fidl :: Error > { let mut request_stream = requests . into_stream ( ) ? ; while let Some ( request ) = request_stream . try_next ( ) . await ? { match request { fidl_policy :: ClientControllerRequest :: Connect { id , responder , .. } => { match handle_client_request_connect ( Arc :: clone ( & client ) , Arc :: clone ( & saved_networks ) , & id , ) . await { Ok ( ( cred , txn ) ) => { responder . send ( fidl_common :: RequestStatus :: Acknowledged ) ? ; // TODO(hahnr): Send connecting update. let _ignored = internal_msg_sink . unbounded_send ( InternalMsg :: NewPendingConnectRequest ( id , cred , txn ) ) ; } Err ( error ) => { error ! ( " " error cause ) ; responder . send ( error . status ) ? ; } } } fidl_policy :: ClientControllerRequest :: StartClientConnections { responder } => { let status = handle_client_request_start_connections ( ) ; responder . send ( status ) ? ; } fidl_policy :: ClientControllerRequest :: StopClientConnections { responder } => { let status = handle_client_request_stop_connections ( ) ; responder . send ( status ) ? ; } fidl_policy :: ClientControllerRequest :: ScanForNetworks { iterator , .. } => { handle_client_request_scan ( iterator ) . await ? ; } fidl_policy :: ClientControllerRequest :: SaveNetwork { config , responder } => { // If there is an error saving the network, log it and convert to a FIDL value. let mut response = handle_client_request_save_network ( Arc :: clone ( & saved_networks ) , config ) . map_err ( | e | { error ! ( " " e ) ; fidl_policy :: NetworkConfigChangeError :: from ( e ) } ) ; responder . send ( & mut response ) ? ; } fidl_policy :: ClientControllerRequest :: RemoveNetwork { config , responder } => { let mut err = handle_client_request_remove_network ( Arc :: clone ( & saved_networks ) , config ) . map_err ( | _ | SaveError :: GeneralError ) ; responder . send ( & mut err ) ? ; } fidl_policy :: ClientControllerRequest :: GetSavedNetworks { iterator , .. } => { handle_client_request_get_networks ( Arc :: clone ( & saved_networks ) , iterator ) . await ? ; } } } Ok ( ( ) ) }
Handles all incoming requests from a ClientController.
Handles all incoming requests from a ClientController .
client
ClientPtr
internal_msg_sink
InternalMsgSink
saved_networks
SavedNetworksPtr
requests
ClientRequests
client
ClientPtr
internal_msg_sink
InternalMsgSink
saved_networks
SavedNetworksPtr
requests
ClientRequests