async fn handle_client_request_connect(
    client: ClientPtr,
    saved_networks: SavedNetworksPtr,
    network: &fidl_policy::NetworkIdentifier,
) -> Result<(Credential, fidl_sme::ConnectTransactionProxy), RequestError> {
    let network_config = saved_networks
        .lookup(NetworkIdentifier::new(network.ssid.clone(), network.type_.into()))
        .pop()
        .ok_or_else(|| {
            RequestError::new().with_cause(format_err!(
                "error network not found: {}",
                String::from_utf8_lossy(&network.ssid)
            ))
        })?;

    // TODO(hahnr): Discuss whether every request should verify the existence of a Client, or
    // whether that should be handled by either, closing the currently active controller if a
    // client interface is brought down and not supporting controller requests if no client
    // interface is active.
    let client = client.lock();
    let client_sme = client.access_sme().ok_or_else(|| {
        RequestError::new().with_cause(format_err!("error no active client interface"))
    })?;

    let credential = sme_credential_from_policy(&network_config.credential);
    let mut request = fidl_sme::ConnectRequest {
        ssid: network.ssid.to_vec(),
        credential,
        radio_cfg: fidl_sme::RadioConfig {
            override_phy: false,
            phy: fidl_common::Phy::Vht,
            override_cbw: false,
            cbw: fidl_common::Cbw::Cbw80,
            override_primary_chan: false,
            primary_chan: 0,
        },
        scan_type: fidl_common::ScanType::Passive,
    };
    let (local, remote) = fidl::endpoints::create_proxy()?;
    client_sme.connect(&mut request, Some(remote))?;

    Ok((network_config.credential, local))
}
/// Attempts to issue a new connect request to the currently active Client.
/// The network's configuration must have been stored before issuing a connect request.
Attempts to issue a new connect request to the currently active Client.
The network's configuration must have been stored before issuing a connect request.
Attempts to issue a new connect request to the currently active Client . The network ' s configuration must have been stored before issuing a connect request .
async fn handle_client_request_connect(
    client: ClientPtr,
    saved_networks: SavedNetworksPtr,
    network: &fidl_policy::NetworkIdentifier,
) -> Result<(Credential, fidl_sme::ConnectTransactionProxy), RequestError> {
    let network_config = saved_networks
        .lookup(NetworkIdentifier::new(network.ssid.clone(), network.type_.into()))
        .pop()
        .ok_or_else(|| {
            RequestError::new().with_cause(format_err!(
                "error network not found: {}",
                String::from_utf8_lossy(&network.ssid)
            ))
        })?;
    // TODO(hahnr): Discuss whether every request should verify the existence of a Client, or
    // whether that should be handled by either, closing the currently active controller if a
    // client interface is brought down and not supporting controller requests if no client
    // interface is active.
    let client = client.lock();
    let client_sme = client.access_sme().ok_or_else(|| {
        RequestError::new().with_cause(format_err!("error no active client interface"))
    })?;
    let credential = sme_credential_from_policy(&network_config.credential);
    let mut request = fidl_sme::ConnectRequest {
        ssid: network.ssid.to_vec(),
        credential,
        radio_cfg: fidl_sme::RadioConfig {
            override_phy: false,
            phy: fidl_common::Phy::Vht,
            override_cbw: false,
            cbw: fidl_common::Cbw::Cbw80,
            override_primary_chan: false,
            primary_chan: 0,
        },
        scan_type: fidl_common::ScanType::Passive,
    };
    let (local, remote) = fidl::endpoints::create_proxy()?;
    client_sme.connect(&mut request, Some(remote))?;
    Ok((network_config.credential, local))
}
async fn handle_client_request_connect ( client : ClientPtr , saved_networks : SavedNetworksPtr , network : & fidl_policy :: NetworkIdentifier , ) -> Result < ( Credential , fidl_sme :: ConnectTransactionProxy ) , RequestError > { let network_config = saved_networks . lookup ( NetworkIdentifier :: new ( network . ssid . clone ( ) , network . type_ . into ( ) ) ) . pop ( ) . ok_or_else ( | | { RequestError :: new ( ) . with_cause ( format_err ! ( " " String from_utf8_lossy ( network ssid ) ) ) } ) ? ; // TODO(hahnr): Discuss whether every request should verify the existence of a Client, or // whether that should be handled by either, closing the currently active controller if a // client interface is brought down and not supporting controller requests if no client // interface is active. let client = client . lock ( ) ; let client_sme = client . access_sme ( ) . ok_or_else ( | | { RequestError :: new ( ) . with_cause ( format_err ! ( " " ) ) } ) ? ; let credential = sme_credential_from_policy ( & network_config . credential ) ; let mut request = fidl_sme :: ConnectRequest { ssid : network . ssid . to_vec ( ) , credential , radio_cfg : fidl_sme :: RadioConfig { override_phy : false , phy : fidl_common :: Phy :: Vht , override_cbw : false , cbw : fidl_common :: Cbw :: Cbw80 , override_primary_chan : false , primary_chan : 0 , } , scan_type : fidl_common :: ScanType :: Passive , } ; let ( local , remote ) = fidl :: endpoints :: create_proxy ( ) ? ; client_sme . connect ( & mut request , Some ( remote ) ) ? ; Ok ( ( network_config . credential , local ) ) }
Attempts to issue a new connect request to the currently active Client.
Attempts to issue a new connect request to the currently active Client .
client
ClientPtr
saved_networks
SavedNetworksPtr
network
&fidl_policy::NetworkIdentifier
client
ClientPtr
saved_networks
SavedNetworksPtr
network
&fidl_policy::NetworkIdentifier