pub async fn scan_networks(&self) -> Result<(), CaptivePortalError> {
        use generated::device::DeviceWireless;
        let p = nonblock::Proxy::new(NM_BUSNAME, self.wifi_device_path.clone(), self.conn.clone());

        // request_scan requires a hashmap of dbus::arg::RefArg parameters as argument.
        // Those are not thread safe, eg implement Send, so cannot be wrapped as intermediate state in the
        // async state machine. A function scope helps out here.
        fn scan_networks(p: dbus::nonblock::Proxy<Arc<SyncConnection>>) -> dbus::nonblock::MethodReply<()> {
            p.request_scan(HashMap::new())
        }

        // There is one error that we can expect by calling this method:
        // org.freedesktop.NetworkManager.Device.NotAllowed - Scanning not allowed while already scanning
        if let Err(e) = scan_networks(p).await {
            if let Some(name) = e.name() {
                // All good
                if name == "org.freedesktop.NetworkManager.Device.NotAllowed" {
                    return Ok(());
                }
            }
            return Err(e.into());
        }

        Ok(())
    }
/// Scan for access points if the last scan is older than 10 seconds
Scan for access points if the last scan is older than 10 seconds
Scan for access points if the last scan is older than 10 seconds
pub async fn scan_networks(&self) -> Result<(), CaptivePortalError> {
        use generated::device::DeviceWireless;
        let p = nonblock::Proxy::new(NM_BUSNAME, self.wifi_device_path.clone(), self.conn.clone());
        // request_scan requires a hashmap of dbus::arg::RefArg parameters as argument.
        // Those are not thread safe, eg implement Send, so cannot be wrapped as intermediate state in the
        // async state machine. A function scope helps out here.
        fn scan_networks(p: dbus::nonblock::Proxy<Arc<SyncConnection>>) -> dbus::nonblock::MethodReply<()> {
            p.request_scan(HashMap::new())
        }
        // There is one error that we can expect by calling this method:
        // org.freedesktop.NetworkManager.Device.NotAllowed - Scanning not allowed while already scanning
        if let Err(e) = scan_networks(p).await {
            if let Some(name) = e.name() {
                // All good
                if name == "org.freedesktop.NetworkManager.Device.NotAllowed" {
                    return Ok(());
                }
            }
            return Err(e.into());
        }
        Ok(())
    }
pub async fn scan_networks ( & self ) -> Result < ( ) , CaptivePortalError > { use generated :: device :: DeviceWireless ; let p = nonblock :: Proxy :: new ( NM_BUSNAME , self . wifi_device_path . clone ( ) , self . conn . clone ( ) ) ; // request_scan requires a hashmap of dbus::arg::RefArg parameters as argument. // Those are not thread safe, eg implement Send, so cannot be wrapped as intermediate state in the // async state machine. A function scope helps out here. fn scan_networks ( p : dbus :: nonblock :: Proxy < Arc < SyncConnection > > ) -> dbus :: nonblock :: MethodReply < ( ) > { p . request_scan ( HashMap :: new ( ) ) } // There is one error that we can expect by calling this method: // org.freedesktop.NetworkManager.Device.NotAllowed - Scanning not allowed while already scanning if let Err ( e ) = scan_networks ( p ) . await { if let Some ( name ) = e . name ( ) { // All good if name == " " { return Ok ( ( ) ) ; } } return Err ( e . into ( ) ) ; } Ok ( ( ) ) }
Scan for access points if the last scan is older than 10 seconds
Scan for access points if the last scan is older than 10 seconds
&self
&self