Expand description
§systemconfiguration-rs
Safe Rust bindings for Apple’s SystemConfiguration.framework on macOS.
Version 0.4.0 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 need async notification streams, enable the async feature. 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 current bridge release:
DynamicStoreNetworkConfigurationoverview helpersNetworkConnectionReachability/NetworkReachabilityPreferencesSchemaNetworkServiceNetworkSetNetworkInterfaceBondInterfaceVlanInterfaceNetworkProtocolConsoleUserCaptiveNetworkSystemConfigurationerror helpers- Optional
async_apinotification streams (features = ["async"])
See COVERAGE.md for the per-header audit, including the APIs that are intentionally skipped on modern macOS.
§Installation
[dependencies]
systemconfiguration-rs = "0.4"Enable async notification streams when needed:
[dependencies]
systemconfiguration-rs = { version = "0.4", features = ["async"] }Enable raw C access when needed:
[dependencies]
systemconfiguration-rs = { version = "0.4", features = ["raw-ffi"] }The crate name is systemconfiguration-rs; the Rust library name is
systemconfiguration.
§Quick start
use systemconfiguration::{DynamicStore, NetworkConfiguration, Reachability};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = DynamicStore::new("com.example.systemconfiguration-rs")?;
println!("computer_name={:?}", store.computer_name());
let reachability = Reachability::with_name("apple.com")?;
println!("apple.com => {}", reachability.flags()?);
let overview = NetworkConfiguration::overview()?;
println!(
"interfaces={} services={} current_set={:?}",
overview.interface_count,
overview.service_count,
overview.current_set_name
);
Ok(())
}§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
- Optional
asyncfeature exposingDynamicStoreNotificationStream,ReachabilityStream, andPreferencesNotificationStreambacked bydoom-fish-utils::stream::BoundedAsyncStream raw-ffifeature preserving direct access to the underlying C APIs already declared by the crate- 14 numbered examples under
examples/and 15 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 individual examples as needed:
cargo run --example 01_dynamic_store_overviewcargo run --example 03_network_reachabilitycargo run --example 06_network_servicescargo run --example 11_captive_networkcargo run --example 50_async_dynamic_store --features asynccargo run --example 51_async_reachability --features asynccargo run --example 52_async_preferences --features async
§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. - Async notification streams own their subscription handles; drop the stream to unsubscribe and tear down the underlying run loop or dispatch queue.
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)
Modules§
- async_
api async - Wraps async SystemConfiguration callback streams.
Async event streams for
SystemConfigurationcallbacks. - prelude
- Re-exports common SystemConfiguration wrapper types.
- raw_ffi
raw-ffi - Wraps raw SystemConfiguration FFI exports.
- schema_
definitions - Wraps constants from
SCSchemaDefinitions.h.
Structs§
- Bond
Interface - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCBondInterfaceRef. - Bond
Status - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCBondStatusRef. - Captive
Network - Re-exports the corresponding SystemConfiguration wrappers. Wraps the CaptiveNetwork support APIs in SystemConfiguration.
- Console
User - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCDynamicStoreCopyConsoleUserresults. - Dynamic
Store - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCDynamicStoreRef. - Dynamic
Store RunLoop Source - Re-exports the corresponding SystemConfiguration wrappers.
Wraps the
CFRunLoopSourceRefcreated bySCDynamicStoreCreateRunLoopSource. - Network
Configuration - Re-exports the corresponding SystemConfiguration wrappers. Provides overview helpers for SystemConfiguration network-configuration APIs.
- Network
Configuration Overview - Re-exports the corresponding SystemConfiguration wrappers. Wraps a summary built from SystemConfiguration network-configuration APIs.
- Network
Connection - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkConnectionRef. - Network
Connection User Preferences - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkConnectionCopyUserPreferencesresults. - Network
Interface - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkInterfaceRef. - Network
Interface Media Options - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkInterfaceCopyMediaOptionsresults. - Network
Interface MtuInfo - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkInterfaceCopyMTUresults. - Network
Protocol - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkProtocolRef. - Network
Service - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkServiceRef. - Network
Set - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkSetRef. - Preferences
- Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCPreferencesRef. - Preferences
Notification - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCPreferencesNotification. - Property
List - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
CFPropertyListRefvalues used by SystemConfiguration APIs. - Reachability
- Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkReachabilityRef. - Reachability
Flags - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkReachabilityFlags. - Schema
- Re-exports the corresponding SystemConfiguration wrappers.
Wraps the
SCSchemaDefinitions.hcatalog helpers. - Schema
Catalog - Re-exports the corresponding SystemConfiguration wrappers.
Wraps grouped symbols from
SCSchemaDefinitions.h. - System
Configuration - Re-exports the corresponding SystemConfiguration wrappers. Wraps top-level SystemConfiguration error helpers.
- System
Configuration Error - Re-exports the corresponding SystemConfiguration wrappers. Wraps SystemConfiguration framework failures.
- System
Configuration Last Error - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCCopyLastErrordetails. - Vlan
Interface - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCVLANInterfaceRef.
Enums§
- Network
Connection PppStatus - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkConnectionPPPStatus. - Network
Connection Status - Re-exports the corresponding SystemConfiguration wrappers.
Wraps
SCNetworkConnectionStatus.
Type Aliases§
- Network
Connection Flags - Re-exports the corresponding SystemConfiguration wrappers.
Alias for
SCNetworkConnectionFlagsvalues. - Network
Reachability - Re-exports the corresponding SystemConfiguration wrappers.
Alias for the
SCNetworkReachabilityRefwrapper. - Result
- Re-exports the corresponding SystemConfiguration wrappers. Result alias used by SystemConfiguration wrapper APIs.