Deduplicate network_manager body

This commit is contained in:
Skye 2023-12-16 17:25:51 -05:00
parent c283df795e
commit 17d3c6469e

View file

@ -14,30 +14,15 @@ pub async fn network_manager(
_output: OutputChannel,
dbus_conn: Arc<SyncConnection>,
) -> eyre::Result<Infallible> {
let root_proxy = Proxy::new(
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
Duration::from_secs(5),
dbus_conn.as_ref(),
);
let primary_connection = root_proxy.primary_connection().await?;
let primary_connection_proxy = Proxy::new(
"org.freedesktop.NetworkManager",
primary_connection,
Duration::from_secs(5),
dbus_conn.as_ref(),
);
let destination = "org.freedesktop.NetworkManager";
let timeout = Duration::from_secs(5);
let connection = dbus_conn.as_ref();
let make_proxy = |path| Proxy::new(destination, path, timeout, connection);
let specific_object = primary_connection_proxy.specific_object().await?;
let specific_object_proxy = Proxy::new(
"org.freedesktop.NetworkManager",
specific_object,
Duration::from_secs(5),
dbus_conn.as_ref(),
);
let ssid = specific_object_proxy.ssid().await?;
let primary_connection = make_proxy("/org/freedesktop/NetworkManager".into()).primary_connection().await?;
let specific_object = make_proxy(primary_connection).specific_object().await?;
let ssid = make_proxy(specific_object).ssid().await?;
log::warn!("got ssid: {}", String::from_utf8_lossy(&ssid));