initial commit, bump nmrs to v3.0
This commit is contained in:
commit
a45d65c2b7
4 changed files with 1311 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/target
|
||||
1263
Cargo.lock
generated
Normal file
1263
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "nmcli-info-rs"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nmrs = "3.0.0"
|
||||
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread"] }
|
||||
39
src/main.rs
Normal file
39
src/main.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use nmrs::NetworkManager;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let nm = NetworkManager::new()
|
||||
.await
|
||||
.expect("failed to initialize NetworkManager connection");
|
||||
let vpns = nm
|
||||
.list_vpn_connections()
|
||||
.await
|
||||
.expect("unable to parse vpn connections");
|
||||
//let cons = nm.list_networks()
|
||||
//let vpn_list = nm.get_vpn_info(name)
|
||||
for v in vpns {
|
||||
println!("Name: {}, State: {}", v.name, v.state)
|
||||
}
|
||||
//println!("VPNs: {:#?}", vpns);
|
||||
|
||||
// let interface = nm.get_device_by_interface("wlan0");
|
||||
let wlan_devs = nm
|
||||
.list_devices()
|
||||
.await
|
||||
.expect("could not gather wifi devices");
|
||||
for dev in wlan_devs {
|
||||
println!("{}: {} ({})", dev.interface, dev.device_type, dev.state);
|
||||
}
|
||||
let wifi_connections = nm
|
||||
.list_networks(None)
|
||||
.await
|
||||
.expect("unable to parse networks")
|
||||
.into_iter()
|
||||
.filter(|x| x.is_active);
|
||||
//let ww = nm.list_networks()
|
||||
for w in wifi_connections {
|
||||
println!("WiFi Name: {}", w.ssid);
|
||||
//println!()
|
||||
}
|
||||
//println!("Networks: {:#?}", networks);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue