systemconfiguration-rs
Safe Rust bindings for Apple’s SystemConfiguration.framework on macOS.
Version 0.2.1 continues the screencapturekit-rs-style Swift bridge
introduced in 0.2.0: Cargo builds a small SwiftPM static library, Rust owns
opaque retained handles, and the public API stays ergonomic on the Rust side.
If you still need low-level C symbols, enable the raw-ffi feature.
Covered areas
systemconfiguration-rs now ships safe wrappers for the logical areas covered
by the 0.2.1 bridge release:
DynamicStoreNetworkConfigurationoverview helpersNetworkConnectionReachability/NetworkReachabilityPreferencesSchemaNetworkServiceNetworkSetNetworkInterfaceBondInterfaceVlanInterfaceNetworkProtocolConsoleUserCaptiveNetworkSystemConfigurationerror helpers
See COVERAGE.md for the per-header audit, including the APIs that are still partial or intentionally skipped on macOS.
Installation
[]
= "0.2"
Enable raw C access when needed:
[]
= { = "0.2", = ["raw-ffi"] }
The crate name is systemconfiguration-rs; the Rust library name is
systemconfiguration.
Quick start
use ;
Highlights
- Swift bridge primary implementation with one Swift file per logical area
- Safe Rust wrappers for property lists, preferences sessions, dynamic-store callbacks, services, sets, interfaces, bond/VLAN configuration, network connections, reachability, captive-network helpers, console-user lookup, and SystemConfiguration error helpers
raw-ffifeature preserving direct access to the underlying C APIs already declared by the crate- 11 numbered examples under
examples/and 12 smoke tests undertests/
Architecture
build.rsbuildsswift-bridge/Package.swiftinto a static library and links it into the Rust crate.- Swift bridge entry points are
@_cdeclfunctions returning C primitives or opaque retained pointers. - Rust owns those handles via
OwnedHandleinsrc/bridge.rsand releases them through shared bridge retain/release functions. - Some structured results are serialized as JSON in Swift and decoded with
serdeon the Rust side.
Examples
Run all examples exactly as used during verification:
for; do
done
Handy entry points:
cargo run --example 01_dynamic_store_overviewcargo run --example 03_network_reachabilitycargo run --example 06_network_servicescargo run --example 11_captive_network
API notes
- Writing to the dynamic store or preferences can require elevated privileges; read-only smoke examples are used where the host environment denies mutation.
- Apple deprecates
SCNetworkReachability*in favor ofNetwork.framework, but these APIs remain wrapped because they are still widely deployed. CaptiveNetworkdoes not wrapCNCopyCurrentNetworkInfo, because that API is unavailable on modern macOS and generally entitlement-gated.Schema::catalog()now exposes the fullSCSchemaDefinitions.hcatalog inSchemaCatalog::all, while keeping the original curated convenience groups.
License
Licensed under either of:
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)