diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0b1205..d646dfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: matrix: # MSRV. Not considered breaking when this has to be bumped. # But should be mentioned in the changelog. - rust: [stable, beta, nightly, 1.56.0] + rust: [stable, beta, nightly, 1.64.0] runs-on: macos-latest steps: - uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index cc55d91..a72625a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ Line wrap the file at 100 chars. Th ## [Unreleased] +### Changed +- Bump minimum supported Rust version (MSRV) to 1.64.0. ## [0.5.1] - 2023-05-15 diff --git a/generate_bindings.sh b/generate_bindings.sh index 481c42a..b21e98f 100755 --- a/generate_bindings.sh +++ b/generate_bindings.sh @@ -86,11 +86,11 @@ BINDGEN_COMMON_ARGUMENTS=( echo "Generating bindings for $PREFERENCES_HEADER_PATH" bindgen \ "${BINDGEN_COMMON_ARGUMENTS[@]}" \ - --whitelist-function "SCPreferences.*" \ - --blacklist-type "(__)?CF.*" \ - --blacklist-type "Boolean" \ - --blacklist-type "dispatch_queue_[ts]" \ - --blacklist-type "(AuthorizationOpaqueRef|__SCPreferences)" \ + --allowlist-function "SCPreferences.*" \ + --blocklist-type "(__)?CF.*" \ + --blocklist-type "Boolean" \ + --blocklist-type "dispatch_queue_[ts]" \ + --blocklist-type "(AuthorizationOpaqueRef|__SCPreferences)" \ --raw-line "use core::ffi::c_void;" \ --raw-line "use core_foundation_sys::array::CFArrayRef;" \ --raw-line "use core_foundation_sys::base::{Boolean, CFIndex, CFAllocatorRef, CFTypeID};" \ @@ -116,11 +116,11 @@ echo "Generating bindings for $DYNAMIC_STORE_HEADER_PATH" bindgen \ "${BINDGEN_COMMON_ARGUMENTS[@]}" \ - --whitelist-function "SCDynamicStore.*" \ - --whitelist-var "kSCDynamicStore.*" \ - --blacklist-type "(__)?CF.*" \ - --blacklist-type "Boolean" \ - --blacklist-type "dispatch_queue_[ts]" \ + --allowlist-function "SCDynamicStore.*" \ + --allowlist-var "kSCDynamicStore.*" \ + --blocklist-type "(__)?CF.*" \ + --blocklist-type "Boolean" \ + --blocklist-type "dispatch_queue_[ts]" \ --raw-line "use core::ffi::c_void;" \ --raw-line "use core_foundation_sys::array::CFArrayRef;" \ --raw-line "use core_foundation_sys::base::{Boolean, CFIndex, CFAllocatorRef, CFTypeID};" \ @@ -143,16 +143,14 @@ echo "Generating bindings for $DYNAMIC_STORE_COPY_SPECIFIC_HEADER_PATH" bindgen \ "${BINDGEN_COMMON_ARGUMENTS[@]}" \ - --whitelist-function "SCDynamicStoreCopy(ComputerName|ConsoleUser|LocalHostName|Location|Proxies)" \ - --blacklist-type "(__)?CF.*" \ - --blacklist-type "Boolean" \ - --blacklist-type "dispatch_queue_[ts]" \ - --blacklist-type "(__)?SCDynamicStore.*" \ + --allowlist-function "SCDynamicStoreCopy(ComputerName|ConsoleUser|LocalHostName|Location|Proxies)" \ + --blocklist-type "(__)?CF.*" \ + --blocklist-type "Boolean" \ + --blocklist-type "dispatch_queue_[ts]" \ + --blocklist-type "(__)?SCDynamicStore.*" \ --raw-line "use core_foundation_sys::string::{CFStringEncoding, CFStringRef};" \ --raw-line "use core_foundation_sys::dictionary::CFDictionaryRef;" \ --raw-line "use crate::dynamic_store::SCDynamicStoreRef;" \ - --raw-line "" \ - --raw-line "use libc::c_uint;" \ -o $DYNAMIC_STORE_COPY_SPECIFIC_BINDING_PATH \ $DYNAMIC_STORE_COPY_SPECIFIC_HEADER_PATH -- \ -I$SDK_PATH/usr/include \ @@ -166,17 +164,17 @@ echo "Generating bindings for $NETWORK_CONFIGURATION_HEADER_PATH" bindgen \ "${BINDGEN_COMMON_ARGUMENTS[@]}" \ - --whitelist-function "SCNetwork.*" \ - --whitelist-function "SCBondInterface.*" \ - --whitelist-var "kSC(NetworkInterface|BondStatus).*" \ - --blacklist-type "SCNetworkReachability.*" \ - --blacklist-function "SCNetworkReachability.*" \ - --blacklist-type "dispatch_queue_[ts]" \ - --blacklist-type "(__)?CF.*" \ - --blacklist-type "__SC.*" \ - --blacklist-type "Boolean" \ - --blacklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \ - --blacklist-type "(__)?SCPreferences.*" \ + --allowlist-function "SCNetwork.*" \ + --allowlist-function "SCBondInterface.*" \ + --allowlist-var "kSC(NetworkInterface|BondStatus).*" \ + --blocklist-type "SCNetworkReachability.*" \ + --blocklist-function "SCNetworkReachability.*" \ + --blocklist-type "dispatch_queue_[ts]" \ + --blocklist-type "(__)?CF.*" \ + --blocklist-type "__SC.*" \ + --blocklist-type "Boolean" \ + --blocklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \ + --blocklist-type "(__)?SCPreferences.*" \ --raw-line "use core::ffi::c_void;" \ --raw-line "use core_foundation_sys::array::CFArrayRef;" \ --raw-line "use core_foundation_sys::base::{Boolean, CFIndex, CFAllocatorRef, CFTypeID};" \ @@ -185,7 +183,7 @@ bindgen \ --raw-line "use core_foundation_sys::runloop::CFRunLoopRef;" \ --raw-line "" \ --raw-line "use crate::dispatch_queue_t;" \ - --raw-line "use libc::{c_char, c_int, sockaddr, socklen_t};" \ + --raw-line "use libc::{sockaddr, socklen_t};" \ --raw-line "use crate::preferences::SCPreferencesRef;" \ --raw-line "" \ --raw-line "pub type __SCNetworkConnection = c_void;" \ @@ -207,23 +205,23 @@ echo "Generating bindings for $NETWORK_REACHABILITY_HEADER_PATH" bindgen \ "${BINDGEN_COMMON_ARGUMENTS[@]}" \ - --whitelist-function "SCNetworkReachability.*" \ - --whitelist-type "SCNetworkReachability.*" \ - --whitelist-var "kSCNetworkReachability.*" \ - --blacklist-type "sockaddr" \ - --blacklist-type "dispatch_queue_[ts]" \ - --blacklist-type "(__)?CF.*" \ - --blacklist-type "__SC.*" \ - --blacklist-type "Boolean" \ - --blacklist-type "dispatch_.*" \ - --blacklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \ + --allowlist-function "SCNetworkReachability.*" \ + --allowlist-type "SCNetworkReachability.*" \ + --allowlist-var "kSCNetworkReachability.*" \ + --blocklist-type "sockaddr" \ + --blocklist-type "dispatch_queue_[ts]" \ + --blocklist-type "(__)?CF.*" \ + --blocklist-type "__SC.*" \ + --blocklist-type "Boolean" \ + --blocklist-type "dispatch_.*" \ + --blocklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \ --raw-line '#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]' \ --raw-line "use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFTypeID, CFIndex};" \ --raw-line "use core_foundation_sys::string::CFStringRef;" \ --raw-line "use core_foundation_sys::runloop::CFRunLoopRef;" \ - --raw-line "use libc::{c_char, sockaddr, c_void};" \ + --raw-line "use libc::sockaddr;" \ --raw-line "use crate::dispatch_queue_t;" \ - --raw-line "pub type __SCNetworkReachability = c_void;" \ + --raw-line "pub type __SCNetworkReachability = ::core::ffi::c_void;" \ -o $NETWORK_REACHABILITY_BINDING_PATH \ $NETWORK_REACHABILITY_HEADER_PATH -- \ -I$SDK_PATH/usr/include \ @@ -238,9 +236,9 @@ echo "Generating bindings for $SCHEMA_DEFINITIONS_HEADER_PATH" bindgen \ "${BINDGEN_COMMON_ARGUMENTS[@]}" \ - --whitelist-var "kSC.*" \ - --blacklist-type "(__)?CF.*" \ - --blacklist-type "dispatch_queue_[ts]" \ + --allowlist-var "kSC.*" \ + --blocklist-type "(__)?CF.*" \ + --blocklist-type "dispatch_queue_[ts]" \ --raw-line "use core_foundation_sys::string::CFStringRef;" \ --raw-line "" \ -o $SCHEMA_DEFINITIONS_BINDING_PATH \ diff --git a/system-configuration-sys/src/dynamic_store.rs b/system-configuration-sys/src/dynamic_store.rs index 8dd9ce7..76e7739 100644 --- a/system-configuration-sys/src/dynamic_store.rs +++ b/system-configuration-sys/src/dynamic_store.rs @@ -1,8 +1,8 @@ -// automatically generated by rust-bindgen +/* automatically generated by rust-bindgen 0.66.1 */ // Generated using: -// bindgen 0.54.0 -// macOS SDK 10.15.4. +// bindgen 0.66.1 +// macOS SDK 13.3. use core::ffi::c_void; use core_foundation_sys::array::CFArrayRef; diff --git a/system-configuration-sys/src/dynamic_store_copy_specific.rs b/system-configuration-sys/src/dynamic_store_copy_specific.rs index 5788605..cb0f237 100644 --- a/system-configuration-sys/src/dynamic_store_copy_specific.rs +++ b/system-configuration-sys/src/dynamic_store_copy_specific.rs @@ -1,21 +1,19 @@ -// automatically generated by rust-bindgen +/* automatically generated by rust-bindgen 0.66.1 */ // Generated using: -// bindgen 0.54.0 -// macOS SDK 10.15.4. +// bindgen 0.66.1 +// macOS SDK 13.3. use crate::dynamic_store::SCDynamicStoreRef; use core_foundation_sys::dictionary::CFDictionaryRef; use core_foundation_sys::string::{CFStringEncoding, CFStringRef}; -use libc::c_uint; - -pub type __uint32_t = c_uint; +pub type __uint32_t = ::core::ffi::c_uint; pub type __darwin_gid_t = __uint32_t; pub type __darwin_uid_t = __uint32_t; pub type gid_t = __darwin_gid_t; pub type uid_t = __darwin_uid_t; -pub type UInt32 = c_uint; +pub type UInt32 = ::core::ffi::c_uint; extern "C" { pub fn SCDynamicStoreCopyComputerName( store: SCDynamicStoreRef, diff --git a/system-configuration-sys/src/network_configuration.rs b/system-configuration-sys/src/network_configuration.rs index 686bf87..037ef28 100644 --- a/system-configuration-sys/src/network_configuration.rs +++ b/system-configuration-sys/src/network_configuration.rs @@ -1,8 +1,8 @@ -// automatically generated by rust-bindgen +/* automatically generated by rust-bindgen 0.66.1 */ // Generated using: -// bindgen 0.54.0 -// macOS SDK 10.15.4. +// bindgen 0.66.1 +// macOS SDK 13.3. use core::ffi::c_void; use core_foundation_sys::array::CFArrayRef; @@ -13,7 +13,7 @@ use core_foundation_sys::string::CFStringRef; use crate::dispatch_queue_t; use crate::preferences::SCPreferencesRef; -use libc::{c_char, c_int, sockaddr, socklen_t}; +use libc::{sockaddr, socklen_t}; pub type __SCNetworkConnection = c_void; pub type __SCNetworkInterface = c_void; @@ -31,7 +31,7 @@ extern "C" { ) -> Boolean; pub fn SCNetworkCheckReachabilityByName( - nodename: *const c_char, + nodename: *const ::core::ffi::c_char, flags: *mut SCNetworkConnectionFlags, ) -> Boolean; @@ -126,8 +126,6 @@ extern "C" { pub static kSCNetworkInterfaceTypeBond: CFStringRef; - pub static kSCNetworkInterfaceTypeBridge: CFStringRef; - pub static kSCNetworkInterfaceTypeEthernet: CFStringRef; pub static kSCNetworkInterfaceTypeFireWire: CFStringRef; @@ -163,7 +161,7 @@ pub const kSCBondStatusLinkInvalid: _bindgen_ty_286 = 1; pub const kSCBondStatusNoPartner: _bindgen_ty_286 = 2; pub const kSCBondStatusNotInActiveGroup: _bindgen_ty_286 = 3; pub const kSCBondStatusUnknown: _bindgen_ty_286 = 999; -pub type _bindgen_ty_286 = u32; +pub type _bindgen_ty_286 = ::core::ffi::c_uint; extern "C" { pub static kSCBondStatusDeviceAggregationStatus: CFStringRef; @@ -243,9 +241,9 @@ extern "C" { pub fn SCNetworkInterfaceCopyMTU( interface: SCNetworkInterfaceRef, - mtu_cur: *mut c_int, - mtu_min: *mut c_int, - mtu_max: *mut c_int, + mtu_cur: *mut ::core::ffi::c_int, + mtu_min: *mut ::core::ffi::c_int, + mtu_max: *mut ::core::ffi::c_int, ) -> Boolean; pub fn SCNetworkInterfaceSetMediaOptions( @@ -254,7 +252,10 @@ extern "C" { options: CFArrayRef, ) -> Boolean; - pub fn SCNetworkInterfaceSetMTU(interface: SCNetworkInterfaceRef, mtu: c_int) -> Boolean; + pub fn SCNetworkInterfaceSetMTU( + interface: SCNetworkInterfaceRef, + mtu: ::core::ffi::c_int, + ) -> Boolean; pub fn SCNetworkInterfaceForceConfigurationRefresh(interface: SCNetworkInterfaceRef) -> Boolean; diff --git a/system-configuration-sys/src/network_reachability.rs b/system-configuration-sys/src/network_reachability.rs index 788ffac..3881adb 100644 --- a/system-configuration-sys/src/network_reachability.rs +++ b/system-configuration-sys/src/network_reachability.rs @@ -1,16 +1,16 @@ -// automatically generated by rust-bindgen +/* automatically generated by rust-bindgen 0.66.1 */ // Generated using: -// bindgen 0.54.0 -// macOS SDK 10.15.4. +// bindgen 0.66.1 +// macOS SDK 13.3. #![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))] use crate::dispatch_queue_t; use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID}; use core_foundation_sys::runloop::CFRunLoopRef; use core_foundation_sys::string::CFStringRef; -use libc::{c_char, c_void, sockaddr}; -pub type __SCNetworkReachability = c_void; +use libc::sockaddr; +pub type __SCNetworkReachability = ::core::ffi::c_void; pub type SCNetworkReachabilityRef = *const __SCNetworkReachability; #[repr(C)] @@ -25,17 +25,17 @@ pub struct SCNetworkReachabilityContext { Option CFStringRef>, } pub type SCNetworkReachabilityFlags = u32; -pub const kSCNetworkReachabilityFlagsTransientConnection: _bindgen_ty_64 = 1; -pub const kSCNetworkReachabilityFlagsReachable: _bindgen_ty_64 = 2; -pub const kSCNetworkReachabilityFlagsConnectionRequired: _bindgen_ty_64 = 4; -pub const kSCNetworkReachabilityFlagsConnectionOnTraffic: _bindgen_ty_64 = 8; -pub const kSCNetworkReachabilityFlagsInterventionRequired: _bindgen_ty_64 = 16; -pub const kSCNetworkReachabilityFlagsConnectionOnDemand: _bindgen_ty_64 = 32; -pub const kSCNetworkReachabilityFlagsIsLocalAddress: _bindgen_ty_64 = 65536; -pub const kSCNetworkReachabilityFlagsIsDirect: _bindgen_ty_64 = 131072; -pub const kSCNetworkReachabilityFlagsIsWWAN: _bindgen_ty_64 = 262144; -pub const kSCNetworkReachabilityFlagsConnectionAutomatic: _bindgen_ty_64 = 8; -pub type _bindgen_ty_64 = u32; +pub const kSCNetworkReachabilityFlagsTransientConnection: _bindgen_ty_65 = 1; +pub const kSCNetworkReachabilityFlagsReachable: _bindgen_ty_65 = 2; +pub const kSCNetworkReachabilityFlagsConnectionRequired: _bindgen_ty_65 = 4; +pub const kSCNetworkReachabilityFlagsConnectionOnTraffic: _bindgen_ty_65 = 8; +pub const kSCNetworkReachabilityFlagsInterventionRequired: _bindgen_ty_65 = 16; +pub const kSCNetworkReachabilityFlagsConnectionOnDemand: _bindgen_ty_65 = 32; +pub const kSCNetworkReachabilityFlagsIsLocalAddress: _bindgen_ty_65 = 65536; +pub const kSCNetworkReachabilityFlagsIsDirect: _bindgen_ty_65 = 131072; +pub const kSCNetworkReachabilityFlagsIsWWAN: _bindgen_ty_65 = 262144; +pub const kSCNetworkReachabilityFlagsConnectionAutomatic: _bindgen_ty_65 = 8; +pub type _bindgen_ty_65 = ::core::ffi::c_uint; pub type SCNetworkReachabilityCallBack = Option< unsafe extern "C" fn( target: SCNetworkReachabilityRef, @@ -57,7 +57,7 @@ extern "C" { pub fn SCNetworkReachabilityCreateWithName( allocator: CFAllocatorRef, - nodename: *const c_char, + nodename: *const ::core::ffi::c_char, ) -> SCNetworkReachabilityRef; pub fn SCNetworkReachabilityGetTypeID() -> CFTypeID; diff --git a/system-configuration-sys/src/preferences.rs b/system-configuration-sys/src/preferences.rs index c623ad9..4292e48 100644 --- a/system-configuration-sys/src/preferences.rs +++ b/system-configuration-sys/src/preferences.rs @@ -1,8 +1,8 @@ -// automatically generated by rust-bindgen +/* automatically generated by rust-bindgen 0.66.1 */ // Generated using: -// bindgen 0.54.0 -// macOS SDK 10.15.4. +// bindgen 0.66.1 +// macOS SDK 13.3. use core::ffi::c_void; use core_foundation_sys::array::CFArrayRef; diff --git a/system-configuration-sys/src/schema_definitions.rs b/system-configuration-sys/src/schema_definitions.rs index 989e278..7bdca99 100644 --- a/system-configuration-sys/src/schema_definitions.rs +++ b/system-configuration-sys/src/schema_definitions.rs @@ -1,8 +1,8 @@ -// automatically generated by rust-bindgen +/* automatically generated by rust-bindgen 0.66.1 */ // Generated using: -// bindgen 0.54.0 -// macOS SDK 10.15.4. +// bindgen 0.66.1 +// macOS SDK 13.3. use core_foundation_sys::string::CFStringRef; diff --git a/system-configuration/src/network_configuration.rs b/system-configuration/src/network_configuration.rs index 7b503bb..a172cf8 100644 --- a/system-configuration/src/network_configuration.rs +++ b/system-configuration/src/network_configuration.rs @@ -137,6 +137,12 @@ pub enum SCNetworkInterfaceType { IPv4, } +/// Bridge interface type referred to as `kSCNetworkInterfaceTypeBridge` in private headers. +static BRIDGE_INTERFACE_TYPE_ID: &str = "Bridge"; + +/// IrDA interface referenced as `kSCNetworkInterfaceTypeIrDA` but deprecated since macOS 12. +static IRDA_INTERFACE_TYPE_ID: &str = "IrDA"; + impl SCNetworkInterfaceType { /// Tries to construct a type by matching it to string constants used to identify a network /// interface type. If no constants match it, `None` is returned. @@ -152,7 +158,7 @@ impl SCNetworkInterfaceType { Some(SCNetworkInterfaceType::SixToFour) } else if id_is_equal_to(kSCNetworkInterfaceTypeBluetooth) { Some(SCNetworkInterfaceType::Bluetooth) - } else if id_is_equal_to(kSCNetworkInterfaceTypeBridge) { + } else if type_id == &BRIDGE_INTERFACE_TYPE_ID { Some(SCNetworkInterfaceType::Bridge) } else if id_is_equal_to(kSCNetworkInterfaceTypeBond) { Some(SCNetworkInterfaceType::Bond) @@ -164,7 +170,7 @@ impl SCNetworkInterfaceType { Some(SCNetworkInterfaceType::IEEE80211) } else if id_is_equal_to(kSCNetworkInterfaceTypeIPSec) { Some(SCNetworkInterfaceType::IPSec) - } else if id_is_equal_to(kSCNetworkInterfaceTypeIrDA) { + } else if type_id == &IRDA_INTERFACE_TYPE_ID { Some(SCNetworkInterfaceType::IrDA) } else if id_is_equal_to(kSCNetworkInterfaceTypeL2TP) { Some(SCNetworkInterfaceType::L2TP)