async fn serve_provider_requests(
    client: ClientPtr,
    update_sender: listener::MessageSender,
    saved_networks: SavedNetworksPtr,
    mut requests: fidl_policy::ClientProviderRequestStream,
) {
    let (internal_messages_sink, mut internal_messages_stream) = mpsc::unbounded();
    let mut controller_reqs = FuturesUnordered::new();
    let mut pending_con_reqs = FusePending(FuturesOrdered::new());

    loop {
        select! {
            // Progress controller requests.
            _ = controller_reqs.select_next_some() => (),
            // Process provider requests.
            req = requests.select_next_some() => if let Ok(req) = req {
                // If there is an active controller - reject new requests.
                // Rust cannot yet send Epitaphs when closing a channel, thus, simply drop the
                // request.
                if controller_reqs.is_empty() {
                    let fut = handle_provider_request(
                        Arc::clone(&client),
                        internal_messages_sink.clone(),
                        update_sender.clone(),
                        Arc::clone(&saved_networks),
                        req
                    );
                    controller_reqs.push(fut);
                } else {
                    if let Err(e) = reject_provider_request(req) {
                        error!("error sending rejection epitaph");
                    }
                }
            },
            // Progress internal messages.
            msg = internal_messages_stream.select_next_some() => match msg {
                InternalMsg::NewPendingConnectRequest(id, cred, txn) => {
                    let connect_result_fut = txn.take_event_stream().into_future()
                        .map(|(first, _next)| (id, cred, first));
                    pending_con_reqs.push(connect_result_fut);
                }
            },
            // Pending connect request finished.
            resp = pending_con_reqs.select_next_some() => if let (id, cred, Some(Ok(txn))) = resp {
                handle_sme_connect_response(update_sender.clone(), id.into(), cred, txn, Arc::clone(&saved_networks)).await;
            }
        }
    }
}
/// Serves the ClientProvider protocol.
/// Only one ClientController can be active. Additional requests to register ClientControllers
/// will result in their channel being immediately closed.
Serves the ClientProvider protocol.
Only one ClientController can be active. Additional requests to register ClientControllers
will result in their channel being immediately closed.
Serves the ClientProvider protocol . Only one ClientController can be active . Additional requests to register ClientControllers will result in their channel being immediately closed .
async fn serve_provider_requests(
    client: ClientPtr,
    update_sender: listener::MessageSender,
    saved_networks: SavedNetworksPtr,
    mut requests: fidl_policy::ClientProviderRequestStream,
) {
    let (internal_messages_sink, mut internal_messages_stream) = mpsc::unbounded();
    let mut controller_reqs = FuturesUnordered::new();
    let mut pending_con_reqs = FusePending(FuturesOrdered::new());
    loop {
        select! {
            // Progress controller requests.
            _ = controller_reqs.select_next_some() => (),
            // Process provider requests.
            req = requests.select_next_some() => if let Ok(req) = req {
                // If there is an active controller - reject new requests.
                // Rust cannot yet send Epitaphs when closing a channel, thus, simply drop the
                // request.
                if controller_reqs.is_empty() {
                    let fut = handle_provider_request(
                        Arc::clone(&client),
                        internal_messages_sink.clone(),
                        update_sender.clone(),
                        Arc::clone(&saved_networks),
                        req
                    );
                    controller_reqs.push(fut);
                } else {
                    if let Err(e) = reject_provider_request(req) {
                        error!("error sending rejection epitaph");
                    }
                }
            },
            // Progress internal messages.
            msg = internal_messages_stream.select_next_some() => match msg {
                InternalMsg::NewPendingConnectRequest(id, cred, txn) => {
                    let connect_result_fut = txn.take_event_stream().into_future()
                        .map(|(first, _next)| (id, cred, first));
                    pending_con_reqs.push(connect_result_fut);
                }
            },
            // Pending connect request finished.
            resp = pending_con_reqs.select_next_some() => if let (id, cred, Some(Ok(txn))) = resp {
                handle_sme_connect_response(update_sender.clone(), id.into(), cred, txn, Arc::clone(&saved_networks)).await;
            }
        }
    }
}
async fn serve_provider_requests ( client : ClientPtr , update_sender : listener :: MessageSender , saved_networks : SavedNetworksPtr , mut requests : fidl_policy :: ClientProviderRequestStream , ) { let ( internal_messages_sink , mut internal_messages_stream ) = mpsc :: unbounded ( ) ; let mut controller_reqs = FuturesUnordered :: new ( ) ; let mut pending_con_reqs = FusePending ( FuturesOrdered :: new ( ) ) ; loop { select ! { // Progress controller requests. controller_reqs select_next_some ( ) ( ) // Process provider requests. req requests select_next_some ( ) if let Ok ( req ) req { // If there is an active controller - reject new requests. // Rust cannot yet send Epitaphs when closing a channel, thus, simply drop the // request. if controller_reqs is_empty ( ) { let fut handle_provider_request ( Arc clone ( client ) internal_messages_sink clone ( ) update_sender clone ( ) Arc clone ( saved_networks ) req ) controller_reqs push ( fut ) } else { if let Err ( e ) reject_provider_request ( req ) { error ( " " ) } } } // Progress internal messages. msg internal_messages_stream select_next_some ( ) match msg { InternalMsg NewPendingConnectRequest ( id cred txn ) { let connect_result_fut txn take_event_stream ( ) into_future ( ) map ( ( first _next ) ( id cred first ) ) pending_con_reqs push ( connect_result_fut ) } } // Pending connect request finished. resp pending_con_reqs select_next_some ( ) if let ( id cred Some ( Ok ( txn ) ) ) resp { handle_sme_connect_response ( update_sender clone ( ) id into ( ) cred txn Arc clone ( saved_networks ) ) await } } } }
Serves the ClientProvider protocol.
Serves the ClientProvider protocol .
client
ClientPtr
update_sender
listener::MessageSender
saved_networks
SavedNetworksPtr
requests
fidl_policy::ClientProviderRequestStream
client
ClientPtr
update_sender
listener::MessageSender
saved_networks
SavedNetworksPtr
requests
fidl_policy::ClientProviderRequestStream