systemconfiguration-rs 0.5.3

Safe Rust bindings for Apple's SystemConfiguration framework via a Swift bridge on macOS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use systemconfiguration::{NetworkSet, Preferences};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let prefs = Preferences::new("systemconfiguration-rs.network-sets-example", None)?;
    let current = NetworkSet::copy_current(&prefs).and_then(|set| set.name());
    println!("current_set={current:?}");
    for set in NetworkSet::copy_all(&prefs) {
        println!(
            "set_id={:?} name={:?} services={}",
            set.set_id(),
            set.name(),
            set.copy_services().len()
        );
    }
    Ok(())
}