mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-04-19 11:24:24 +02:00
fix: add explicit failure message for DBus property downcasting
This commit is contained in:
parent
68ca8da302
commit
c41d37ca38
1 changed files with 6 additions and 6 deletions
|
@ -56,9 +56,9 @@ impl Module<gtk::Box> for NetworkManagerModule {
|
|||
|
||||
spawn(async move {
|
||||
/* TODO: This should be moved into a client à la the upower module, however that
|
||||
requires additional refactoring as both would request a PropertyProxy but on
|
||||
different buses. The proper solution will be to rewrite both to use trait-derived
|
||||
proxies. */
|
||||
requires additional refactoring as both would request a PropertyProxy but on
|
||||
different buses. The proper solution will be to rewrite both to use trait-derived
|
||||
proxies. */
|
||||
let nm_proxy = {
|
||||
let dbus = zbus::Connection::system().await?;
|
||||
PropertiesProxy::builder(&dbus)
|
||||
|
@ -133,12 +133,12 @@ async fn get_network_state(
|
|||
|
||||
let primary_connection_path = properties["PrimaryConnection"]
|
||||
.downcast_ref::<ObjectPath>()
|
||||
.unwrap();
|
||||
.expect("PrimaryConnection was not an object path, violation of NetworkManager D-Bus interface");
|
||||
|
||||
if primary_connection_path != "/" {
|
||||
let primary_connection_type = properties["PrimaryConnectionType"]
|
||||
.downcast_ref::<str>()
|
||||
.unwrap()
|
||||
.expect("PrimaryConnectionType was not a string, violation of NetworkManager D-Bus interface")
|
||||
.to_string();
|
||||
|
||||
match primary_connection_type.as_str() {
|
||||
|
@ -159,7 +159,7 @@ async fn get_network_state(
|
|||
} else {
|
||||
let wireless_enabled = *properties["WirelessEnabled"]
|
||||
.downcast_ref::<bool>()
|
||||
.unwrap();
|
||||
.expect("WirelessEnabled was not a boolean, violation of NetworkManager D-Bus interface");
|
||||
if wireless_enabled {
|
||||
Ok(NetworkManagerState::WirelessDisconnected)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue