use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
pub const kIOPSPowerAdapterIDKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"AdapterID\0") };
pub const kIOPSPowerAdapterWattsKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Watts\0") };
pub const kIOPSPowerAdapterRevisionKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"AdapterRevision\0") };
pub const kIOPSPowerAdapterSerialNumberKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"SerialNumber\0") };
pub const kIOPSPowerAdapterFamilyKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"FamilyCode\0") };
pub const kIOPSPowerAdapterCurrentKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Current\0") };
pub const kIOPSPowerAdapterSourceKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Source\0") };
pub const kIOPSUPSManagementClaimed: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"/IOKit/UPSPowerManagementClaimed\0") };
pub const kIOPSLowWarnLevelKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Low Warn Level\0") };
pub const kIOPSDeadWarnLevelKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Shutdown Level\0") };
pub const kIOPSDynamicStorePath: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"/IOKit/PowerSources\0") };
pub const kIOPSCommandDelayedRemovePowerKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Delayed Remove Power\0") };
pub const kIOPSCommandEnableAudibleAlarmKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Enable Audible Alarm\0") };
pub const kIOPSCommandStartupDelayKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Startup Delay\0") };
pub const kIOPSCommandSetCurrentLimitKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Set Current Limit\0") };
pub const kIOPSCommandSetRequiredVoltageKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Set Required Voltage\0") };
pub const kIOPSCommandSendCurrentStateOfCharge: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Send Current State of Charge\0") };
pub const kIOPSCommandSendCurrentTemperature: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Send Current Temperature\0") };
pub const kIOPSPowerSourceIDKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Power Source ID\0") };
pub const kIOPSPowerSourceStateKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Power Source State\0") };
pub const kIOPSCurrentCapacityKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Current Capacity\0") };
pub const kIOPSMaxCapacityKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Max Capacity\0") };
pub const kIOPSDesignCapacityKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"DesignCapacity\0") };
pub const kIOPSNominalCapacityKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Nominal Capacity\0") };
pub const kIOPSTimeToEmptyKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Time to Empty\0") };
pub const kIOPSTimeToFullChargeKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Time to Full Charge\0") };
pub const kIOPSIsChargingKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Is Charging\0") };
pub const kIOPSInternalFailureKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Internal Failure\0") };
pub const kIOPSIsPresentKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Is Present\0") };
pub const kIOPSVoltageKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Voltage\0") };
pub const kIOPSCurrentKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Current\0") };
pub const kIOPSTemperatureKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Temperature\0") };
pub const kIOPSNameKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Name\0") };
pub const kIOPSTypeKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Type\0") };
pub const kIOPSTransportTypeKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Transport Type\0") };
pub const kIOPSVendorIDKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Vendor ID\0") };
pub const kIOPSProductIDKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Product ID\0") };
pub const kIOPSVendorDataKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Vendor Specific Data\0") };
pub const kIOPSBatteryHealthKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"BatteryHealth\0") };
pub const kIOPSBatteryHealthConditionKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"BatteryHealthCondition\0") };
pub const kIOPSBatteryFailureModesKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"BatteryFailureModes\0") };
pub const kIOPSHealthConfidenceKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"HealthConfidence\0") };
pub const kIOPSMaxErrKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"MaxErr\0") };
pub const kIOPSIsChargedKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Is Charged\0") };
pub const kIOPSIsFinishingChargeKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Is Finishing Charge\0") };
pub const kIOPSHardwareSerialNumberKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Hardware Serial Number\0") };
pub const kIOPSSerialTransportType: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Serial\0") };
pub const kIOPSUSBTransportType: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"USB\0") };
pub const kIOPSNetworkTransportType: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Ethernet\0") };
pub const kIOPSInternalType: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Internal\0") };
pub const kIOPSInternalBatteryType: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"InternalBattery\0") };
pub const kIOPSUPSType: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"UPS\0") };
pub const kIOPSOffLineValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Off Line\0") };
pub const kIOPSACPowerValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"AC Power\0") };
pub const kIOPSBatteryPowerValue: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Battery Power\0") };
pub const kIOPSPoorValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Poor\0") };
pub const kIOPSFairValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Fair\0") };
pub const kIOPSGoodValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Good\0") };
pub const kIOPSCheckBatteryValue: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Check Battery\0") };
pub const kIOPSPermanentFailureValue: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Permanent Battery Failure\0") };
pub const kIOPSFailureExternalInput: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Externally Indicated Failure\0") };
pub const kIOPSFailureSafetyOverVoltage: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Safety Over-Voltage\0") };
pub const kIOPSFailureChargeOverTemp: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Charge Over-Temperature\0") };
pub const kIOPSFailureDischargeOverTemp: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Discharge Over-Temperature\0") };
pub const kIOPSFailureCellImbalance: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Cell Imbalance\0") };
pub const kIOPSFailureChargeFET: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Charge FET\0") };
pub const kIOPSFailureDischargeFET: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Discharge FET\0") };
pub const kIOPSFailureDataFlushFault: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Data Flush Fault\0") };
pub const kIOPSFailurePermanentAFEComms: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Permanent AFE Comms\0") };
pub const kIOPSFailurePeriodicAFEComms: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Periodic AFE Comms\0") };
pub const kIOPSFailureChargeOverCurrent: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Charge Over-Current\0") };
pub const kIOPSFailureDischargeOverCurrent: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Discharge Over-Current\0") };
pub const kIOPSFailureOpenThermistor: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Open Thermistor\0") };
pub const kIOPSFailureFuseBlown: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Fuse Blown\0") };
pub const kIOPSNotifyLowBattery: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources.lowbattery\0") };
pub const kIOPSNotifyTimeRemaining: &CStr = unsafe {
CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources.timeremaining\0")
};
pub const kIOPSTimeRemainingNotificationKey: &CStr = kIOPSNotifyTimeRemaining;
pub const kIOPSNotifyPowerSource: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources.source\0") };
pub const kIOPSNotifyAttach: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources.attach\0") };
pub const kIOPSNotifyAnyPowerSource: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources\0") };
pub const kIOPSTimeRemainingUnknown: CFTimeInterval = -1.0;
pub const kIOPSTimeRemainingUnlimited: CFTimeInterval = -2.0;
pub const kIOPMUPSPowerKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"UPS Power\0") };
pub const kIOPMBatteryPowerKey: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Battery Power\0") };
pub const kIOPMACPowerKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"AC Power\0") };
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct IOPSLowBatteryWarningLevel(pub c_uint);
impl IOPSLowBatteryWarningLevel {
#[doc(alias = "kIOPSLowBatteryWarningNone")]
pub const None: Self = Self(1);
#[doc(alias = "kIOPSLowBatteryWarningEarly")]
pub const Early: Self = Self(2);
#[doc(alias = "kIOPSLowBatteryWarningFinal")]
pub const Final: Self = Self(3);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for IOPSLowBatteryWarningLevel {
const ENCODING: Encoding = c_uint::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for IOPSLowBatteryWarningLevel {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[inline]
pub extern "C-unwind" fn IOPSGetBatteryWarningLevel() -> IOPSLowBatteryWarningLevel {
extern "C-unwind" {
fn IOPSGetBatteryWarningLevel() -> IOPSLowBatteryWarningLevel;
}
unsafe { IOPSGetBatteryWarningLevel() }
}
#[inline]
pub extern "C-unwind" fn IOPSGetTimeRemainingEstimate() -> CFTimeInterval {
extern "C-unwind" {
fn IOPSGetTimeRemainingEstimate() -> CFTimeInterval;
}
unsafe { IOPSGetTimeRemainingEstimate() }
}
pub type IOPowerSourceCallbackType = Option<unsafe extern "C-unwind" fn(*mut c_void)>;
#[inline]
pub extern "C-unwind" fn IOPSCopyPowerSourcesInfo() -> Option<CFRetained<CFType>> {
extern "C-unwind" {
fn IOPSCopyPowerSourcesInfo() -> Option<NonNull<CFType>>;
}
let ret = unsafe { IOPSCopyPowerSourcesInfo() };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[inline]
pub unsafe extern "C-unwind" fn IOPSCopyPowerSourcesList(
blob: Option<&CFType>,
) -> Option<CFRetained<CFArray>> {
extern "C-unwind" {
fn IOPSCopyPowerSourcesList(blob: Option<&CFType>) -> Option<NonNull<CFArray>>;
}
let ret = unsafe { IOPSCopyPowerSourcesList(blob) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[inline]
pub unsafe extern "C-unwind" fn IOPSGetPowerSourceDescription(
blob: Option<&CFType>,
ps: Option<&CFType>,
) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn IOPSGetPowerSourceDescription(
blob: Option<&CFType>,
ps: Option<&CFType>,
) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { IOPSGetPowerSourceDescription(blob, ps) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
#[inline]
pub unsafe extern "C-unwind" fn IOPSGetProvidingPowerSourceType(
snapshot: Option<&CFType>,
) -> Option<CFRetained<CFString>> {
extern "C-unwind" {
fn IOPSGetProvidingPowerSourceType(snapshot: Option<&CFType>) -> Option<NonNull<CFString>>;
}
let ret = unsafe { IOPSGetProvidingPowerSourceType(snapshot) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
#[inline]
pub unsafe extern "C-unwind" fn IOPSNotificationCreateRunLoopSource(
callback: IOPowerSourceCallbackType,
context: *mut c_void,
) -> Option<CFRetained<CFRunLoopSource>> {
extern "C-unwind" {
fn IOPSNotificationCreateRunLoopSource(
callback: IOPowerSourceCallbackType,
context: *mut c_void,
) -> Option<NonNull<CFRunLoopSource>>;
}
let ret = unsafe { IOPSNotificationCreateRunLoopSource(callback, context) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[inline]
pub unsafe extern "C-unwind" fn IOPSCreateLimitedPowerNotification(
callback: IOPowerSourceCallbackType,
context: *mut c_void,
) -> Option<CFRetained<CFRunLoopSource>> {
extern "C-unwind" {
fn IOPSCreateLimitedPowerNotification(
callback: IOPowerSourceCallbackType,
context: *mut c_void,
) -> Option<NonNull<CFRunLoopSource>>;
}
let ret = unsafe { IOPSCreateLimitedPowerNotification(callback, context) };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
#[inline]
pub extern "C-unwind" fn IOPSCopyExternalPowerAdapterDetails() -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn IOPSCopyExternalPowerAdapterDetails() -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { IOPSCopyExternalPowerAdapterDetails() };
ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}
pub type IOUPSEventCallbackFunction = Option<
unsafe extern "C-unwind" fn(
*mut c_void,
IOReturn,
*mut c_void,
*mut c_void,
*const CFDictionary,
),
>;
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct IOUPSPlugInInterface {
pub(crate) _reserved: *mut c_void,
pub QueryInterface:
Option<unsafe extern "C-unwind" fn(*mut c_void, REFIID, *mut LPVOID) -> HRESULT>,
pub AddRef: Option<unsafe extern "C-unwind" fn(*mut c_void) -> ULONG>,
pub Release: Option<unsafe extern "C-unwind" fn(*mut c_void) -> ULONG>,
pub getProperties:
Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFDictionary) -> IOReturn>,
pub getCapabilities:
Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFSet) -> IOReturn>,
pub getEvent:
Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFDictionary) -> IOReturn>,
pub setEventCallback: Option<
unsafe extern "C-unwind" fn(
*mut c_void,
IOUPSEventCallbackFunction,
*mut c_void,
*mut c_void,
) -> IOReturn,
>,
pub sendCommand:
Option<unsafe extern "C-unwind" fn(*mut c_void, *const CFDictionary) -> IOReturn>,
}
#[cfg(feature = "objc2")]
unsafe impl Encode for IOUPSPlugInInterface {
const ENCODING: Encoding = Encoding::Struct("IOUPSPlugInInterface", &[
<*mut c_void>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,REFIID,*mut LPVOID,) -> HRESULT>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,) -> ULONG>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,) -> ULONG>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFDictionary,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFSet,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFDictionary,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,IOUPSEventCallbackFunction,*mut c_void,*mut c_void,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*const CFDictionary,) -> IOReturn>>::ENCODING,
]);
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for IOUPSPlugInInterface {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct IOUPSPlugInInterface_v140 {
pub(crate) _reserved: *mut c_void,
pub QueryInterface:
Option<unsafe extern "C-unwind" fn(*mut c_void, REFIID, *mut LPVOID) -> HRESULT>,
pub AddRef: Option<unsafe extern "C-unwind" fn(*mut c_void) -> ULONG>,
pub Release: Option<unsafe extern "C-unwind" fn(*mut c_void) -> ULONG>,
pub getProperties:
Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFDictionary) -> IOReturn>,
pub getCapabilities:
Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFSet) -> IOReturn>,
pub getEvent:
Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFDictionary) -> IOReturn>,
pub setEventCallback: Option<
unsafe extern "C-unwind" fn(
*mut c_void,
IOUPSEventCallbackFunction,
*mut c_void,
*mut c_void,
) -> IOReturn,
>,
pub sendCommand:
Option<unsafe extern "C-unwind" fn(*mut c_void, *const CFDictionary) -> IOReturn>,
pub createAsyncEventSource:
Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFType) -> IOReturn>,
}
#[cfg(feature = "objc2")]
unsafe impl Encode for IOUPSPlugInInterface_v140 {
const ENCODING: Encoding = Encoding::Struct("IOUPSPlugInInterface_v140", &[
<*mut c_void>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,REFIID,*mut LPVOID,) -> HRESULT>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,) -> ULONG>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,) -> ULONG>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFDictionary,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFSet,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFDictionary,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,IOUPSEventCallbackFunction,*mut c_void,*mut c_void,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*const CFDictionary,) -> IOReturn>>::ENCODING,
<Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFType,) -> IOReturn>>::ENCODING,
]);
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for IOUPSPlugInInterface_v140 {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}