pub async fn new(interface_name: &Option<String>) -> Result<NetworkBackend, CaptivePortalError> {
        // Prepare an exit handler
        let (exit_handler, exit_receiver) = tokio::sync::oneshot::channel::<()>();

        // Connect to the D-Bus session bus (this is blocking, unfortunately).
        let (resource, conn) = signal_stream::new_system_sync()?;

        // The resource is a task that should be spawned onto a tokio compatible
        // reactor ASAP. If the resource ever finishes, you lost connection to D-Bus.
        tokio::spawn(async move {
            use futures_util::future::select;
            use futures_util::future::Either;
            use pin_utils::pin_mut;

            pin_mut!(resource);
            pin_mut!(exit_receiver);
            let result = select(resource, exit_receiver).await;
            if let Either::Left((err, _)) = result {
                panic!("Lost connection to D-Bus: {}", err);
            }
        });

        let wifi_device = find_wifi_device::find_wifi_device(conn.clone(), interface_name).await?;
        Ok(NetworkBackend {
            exit_handler: Arc::new(Mutex::new(Some(exit_handler))),
            conn,
            interface_name: wifi_device.interface_name,
            hw: wifi_device.hw,
            wifi_device_path: wifi_device.device_path,
        })
    }
/// Create a new connection to the network manager. This will also try to enable networking
/// and wifi. Returns a network manager instance or an error if no wifi device can be found.
Create a new connection to the network manager. This will also try to enable networking
and wifi. Returns a network manager instance or an error if no wifi device can be found.
Create a new connection to the network manager . This will also try to enable networking and wifi . Returns a network manager instance or an error if no wifi device can be found .
pub async fn new(interface_name: &Option<String>) -> Result<NetworkBackend, CaptivePortalError> {
        // Prepare an exit handler
        let (exit_handler, exit_receiver) = tokio::sync::oneshot::channel::<()>();
        // Connect to the D-Bus session bus (this is blocking, unfortunately).
        let (resource, conn) = signal_stream::new_system_sync()?;
        // The resource is a task that should be spawned onto a tokio compatible
        // reactor ASAP. If the resource ever finishes, you lost connection to D-Bus.
        tokio::spawn(async move {
            use futures_util::future::select;
            use futures_util::future::Either;
            use pin_utils::pin_mut;
            pin_mut!(resource);
            pin_mut!(exit_receiver);
            let result = select(resource, exit_receiver).await;
            if let Either::Left((err, _)) = result {
                panic!("Lost connection to D-Bus: {}", err);
            }
        });
        let wifi_device = find_wifi_device::find_wifi_device(conn.clone(), interface_name).await?;
        Ok(NetworkBackend {
            exit_handler: Arc::new(Mutex::new(Some(exit_handler))),
            conn,
            interface_name: wifi_device.interface_name,
            hw: wifi_device.hw,
            wifi_device_path: wifi_device.device_path,
        })
    }
pub async fn new ( interface_name : & Option < String > ) -> Result < NetworkBackend , CaptivePortalError > { // Prepare an exit handler let ( exit_handler , exit_receiver ) = tokio :: sync :: oneshot :: channel :: < ( ) > ( ) ; // Connect to the D-Bus session bus (this is blocking, unfortunately). let ( resource , conn ) = signal_stream :: new_system_sync ( ) ? ; // The resource is a task that should be spawned onto a tokio compatible // reactor ASAP. If the resource ever finishes, you lost connection to D-Bus. tokio :: spawn ( async move { use futures_util :: future :: select ; use futures_util :: future :: Either ; use pin_utils :: pin_mut ; pin_mut ! ( resource ) ; pin_mut ! ( exit_receiver ) ; let result = select ( resource , exit_receiver ) . await ; if let Either :: Left ( ( err , _ ) ) = result { panic ! ( " " err ) ; } } ) ; let wifi_device = find_wifi_device :: find_wifi_device ( conn . clone ( ) , interface_name ) . await ? ; Ok ( NetworkBackend { exit_handler : Arc :: new ( Mutex :: new ( Some ( exit_handler ) ) ) , conn , interface_name : wifi_device . interface_name , hw : wifi_device . hw , wifi_device_path : wifi_device . device_path , } ) }
Create a new connection to the network manager.
Create a new connection to the network manager .
interface_name
&Option<String>
interface_name
&Option<String>