index : nmrs-tui
A fast, Vim-friendly NetworkManager TUI built in Rust.
about summary refs log tree commit diff

Diffstat (limited to 'src/nm/client.rs')

-rw-r--r-- src/nm/client.rs 25
 1 file changed, 25 insertions(+)

diff --git a/src/nm/client.rs b/src/nm/client.rs
new file mode 100644
index 0000000..43aab44 100644
--- /dev/null
+++ b/src/nm/client.rs
@@ -1,0 +1,25 @@
use anyhow::Result;
use zbus::{Connection, Proxy};

pub struct NmClient {
    pub connection: Connection,
    pub proxy: Proxy<'static>,
}

impl NmClient {
    pub async fn new() -> Result<Self> {
        // Connect to system D-Bus
        let connection = Connection::system().await?;

        // Create NetworkManager proxy
        let proxy = Proxy::new(
            &connection,
            "org.freedesktop.NetworkManager",
            "/org/freedesktop/NetworkManager",
            "org.freedesktop.NetworkManager",
        )
        .await?;

        Ok(Self { connection, proxy })
    }
}