objc2_io_kit/generated/ps.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspoweradapteridkey?language=objc)
12pub const kIOPSPowerAdapterIDKey: &CStr =
13 unsafe { CStr::from_bytes_with_nul_unchecked(b"AdapterID\0") };
14/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspoweradapterwattskey?language=objc)
15pub const kIOPSPowerAdapterWattsKey: &CStr =
16 unsafe { CStr::from_bytes_with_nul_unchecked(b"Watts\0") };
17/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspoweradapterrevisionkey?language=objc)
18pub const kIOPSPowerAdapterRevisionKey: &CStr =
19 unsafe { CStr::from_bytes_with_nul_unchecked(b"AdapterRevision\0") };
20/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspoweradapterserialnumberkey?language=objc)
21pub const kIOPSPowerAdapterSerialNumberKey: &CStr =
22 unsafe { CStr::from_bytes_with_nul_unchecked(b"SerialNumber\0") };
23/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspoweradapterfamilykey?language=objc)
24pub const kIOPSPowerAdapterFamilyKey: &CStr =
25 unsafe { CStr::from_bytes_with_nul_unchecked(b"FamilyCode\0") };
26/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspoweradaptercurrentkey?language=objc)
27pub const kIOPSPowerAdapterCurrentKey: &CStr =
28 unsafe { CStr::from_bytes_with_nul_unchecked(b"Current\0") };
29/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspoweradaptersourcekey?language=objc)
30pub const kIOPSPowerAdapterSourceKey: &CStr =
31 unsafe { CStr::from_bytes_with_nul_unchecked(b"Source\0") };
32/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsupsmanagementclaimed?language=objc)
33pub const kIOPSUPSManagementClaimed: &CStr =
34 unsafe { CStr::from_bytes_with_nul_unchecked(b"/IOKit/UPSPowerManagementClaimed\0") };
35/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopslowwarnlevelkey?language=objc)
36pub const kIOPSLowWarnLevelKey: &CStr =
37 unsafe { CStr::from_bytes_with_nul_unchecked(b"Low Warn Level\0") };
38/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsdeadwarnlevelkey?language=objc)
39pub const kIOPSDeadWarnLevelKey: &CStr =
40 unsafe { CStr::from_bytes_with_nul_unchecked(b"Shutdown Level\0") };
41/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsdynamicstorepath?language=objc)
42pub const kIOPSDynamicStorePath: &CStr =
43 unsafe { CStr::from_bytes_with_nul_unchecked(b"/IOKit/PowerSources\0") };
44/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscommanddelayedremovepowerkey?language=objc)
45pub const kIOPSCommandDelayedRemovePowerKey: &CStr =
46 unsafe { CStr::from_bytes_with_nul_unchecked(b"Delayed Remove Power\0") };
47/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscommandenableaudiblealarmkey?language=objc)
48pub const kIOPSCommandEnableAudibleAlarmKey: &CStr =
49 unsafe { CStr::from_bytes_with_nul_unchecked(b"Enable Audible Alarm\0") };
50/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscommandstartupdelaykey?language=objc)
51pub const kIOPSCommandStartupDelayKey: &CStr =
52 unsafe { CStr::from_bytes_with_nul_unchecked(b"Startup Delay\0") };
53/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscommandsetcurrentlimitkey?language=objc)
54pub const kIOPSCommandSetCurrentLimitKey: &CStr =
55 unsafe { CStr::from_bytes_with_nul_unchecked(b"Set Current Limit\0") };
56/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscommandsetrequiredvoltagekey?language=objc)
57pub const kIOPSCommandSetRequiredVoltageKey: &CStr =
58 unsafe { CStr::from_bytes_with_nul_unchecked(b"Set Required Voltage\0") };
59/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscommandsendcurrentstateofcharge?language=objc)
60pub const kIOPSCommandSendCurrentStateOfCharge: &CStr =
61 unsafe { CStr::from_bytes_with_nul_unchecked(b"Send Current State of Charge\0") };
62/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscommandsendcurrenttemperature?language=objc)
63pub const kIOPSCommandSendCurrentTemperature: &CStr =
64 unsafe { CStr::from_bytes_with_nul_unchecked(b"Send Current Temperature\0") };
65/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspowersourceidkey?language=objc)
66pub const kIOPSPowerSourceIDKey: &CStr =
67 unsafe { CStr::from_bytes_with_nul_unchecked(b"Power Source ID\0") };
68/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspowersourcestatekey?language=objc)
69pub const kIOPSPowerSourceStateKey: &CStr =
70 unsafe { CStr::from_bytes_with_nul_unchecked(b"Power Source State\0") };
71/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscurrentcapacitykey?language=objc)
72pub const kIOPSCurrentCapacityKey: &CStr =
73 unsafe { CStr::from_bytes_with_nul_unchecked(b"Current Capacity\0") };
74/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsmaxcapacitykey?language=objc)
75pub const kIOPSMaxCapacityKey: &CStr =
76 unsafe { CStr::from_bytes_with_nul_unchecked(b"Max Capacity\0") };
77/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsdesigncapacitykey?language=objc)
78pub const kIOPSDesignCapacityKey: &CStr =
79 unsafe { CStr::from_bytes_with_nul_unchecked(b"DesignCapacity\0") };
80/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsnominalcapacitykey?language=objc)
81pub const kIOPSNominalCapacityKey: &CStr =
82 unsafe { CStr::from_bytes_with_nul_unchecked(b"Nominal Capacity\0") };
83/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopstimetoemptykey?language=objc)
84pub const kIOPSTimeToEmptyKey: &CStr =
85 unsafe { CStr::from_bytes_with_nul_unchecked(b"Time to Empty\0") };
86/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopstimetofullchargekey?language=objc)
87pub const kIOPSTimeToFullChargeKey: &CStr =
88 unsafe { CStr::from_bytes_with_nul_unchecked(b"Time to Full Charge\0") };
89/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsischargingkey?language=objc)
90pub const kIOPSIsChargingKey: &CStr =
91 unsafe { CStr::from_bytes_with_nul_unchecked(b"Is Charging\0") };
92/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsinternalfailurekey?language=objc)
93pub const kIOPSInternalFailureKey: &CStr =
94 unsafe { CStr::from_bytes_with_nul_unchecked(b"Internal Failure\0") };
95/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsispresentkey?language=objc)
96pub const kIOPSIsPresentKey: &CStr =
97 unsafe { CStr::from_bytes_with_nul_unchecked(b"Is Present\0") };
98/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsvoltagekey?language=objc)
99pub const kIOPSVoltageKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Voltage\0") };
100/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscurrentkey?language=objc)
101pub const kIOPSCurrentKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Current\0") };
102/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopstemperaturekey?language=objc)
103pub const kIOPSTemperatureKey: &CStr =
104 unsafe { CStr::from_bytes_with_nul_unchecked(b"Temperature\0") };
105/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsnamekey?language=objc)
106pub const kIOPSNameKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Name\0") };
107/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopstypekey?language=objc)
108pub const kIOPSTypeKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Type\0") };
109/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopstransporttypekey?language=objc)
110pub const kIOPSTransportTypeKey: &CStr =
111 unsafe { CStr::from_bytes_with_nul_unchecked(b"Transport Type\0") };
112/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsvendoridkey?language=objc)
113pub const kIOPSVendorIDKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Vendor ID\0") };
114/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsproductidkey?language=objc)
115pub const kIOPSProductIDKey: &CStr =
116 unsafe { CStr::from_bytes_with_nul_unchecked(b"Product ID\0") };
117/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsvendordatakey?language=objc)
118pub const kIOPSVendorDataKey: &CStr =
119 unsafe { CStr::from_bytes_with_nul_unchecked(b"Vendor Specific Data\0") };
120/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsbatteryhealthkey?language=objc)
121pub const kIOPSBatteryHealthKey: &CStr =
122 unsafe { CStr::from_bytes_with_nul_unchecked(b"BatteryHealth\0") };
123/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsbatteryhealthconditionkey?language=objc)
124pub const kIOPSBatteryHealthConditionKey: &CStr =
125 unsafe { CStr::from_bytes_with_nul_unchecked(b"BatteryHealthCondition\0") };
126/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsbatteryfailuremodeskey?language=objc)
127pub const kIOPSBatteryFailureModesKey: &CStr =
128 unsafe { CStr::from_bytes_with_nul_unchecked(b"BatteryFailureModes\0") };
129/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopshealthconfidencekey?language=objc)
130pub const kIOPSHealthConfidenceKey: &CStr =
131 unsafe { CStr::from_bytes_with_nul_unchecked(b"HealthConfidence\0") };
132/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsmaxerrkey?language=objc)
133pub const kIOPSMaxErrKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"MaxErr\0") };
134/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsischargedkey?language=objc)
135pub const kIOPSIsChargedKey: &CStr =
136 unsafe { CStr::from_bytes_with_nul_unchecked(b"Is Charged\0") };
137/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsisfinishingchargekey?language=objc)
138pub const kIOPSIsFinishingChargeKey: &CStr =
139 unsafe { CStr::from_bytes_with_nul_unchecked(b"Is Finishing Charge\0") };
140/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopshardwareserialnumberkey?language=objc)
141pub const kIOPSHardwareSerialNumberKey: &CStr =
142 unsafe { CStr::from_bytes_with_nul_unchecked(b"Hardware Serial Number\0") };
143/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsserialtransporttype?language=objc)
144pub const kIOPSSerialTransportType: &CStr =
145 unsafe { CStr::from_bytes_with_nul_unchecked(b"Serial\0") };
146/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsusbtransporttype?language=objc)
147pub const kIOPSUSBTransportType: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"USB\0") };
148/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsnetworktransporttype?language=objc)
149pub const kIOPSNetworkTransportType: &CStr =
150 unsafe { CStr::from_bytes_with_nul_unchecked(b"Ethernet\0") };
151/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsinternaltype?language=objc)
152pub const kIOPSInternalType: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Internal\0") };
153/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsinternalbatterytype?language=objc)
154pub const kIOPSInternalBatteryType: &CStr =
155 unsafe { CStr::from_bytes_with_nul_unchecked(b"InternalBattery\0") };
156/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsupstype?language=objc)
157pub const kIOPSUPSType: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"UPS\0") };
158/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsofflinevalue?language=objc)
159pub const kIOPSOffLineValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Off Line\0") };
160/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsacpowervalue?language=objc)
161pub const kIOPSACPowerValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"AC Power\0") };
162/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsbatterypowervalue?language=objc)
163pub const kIOPSBatteryPowerValue: &CStr =
164 unsafe { CStr::from_bytes_with_nul_unchecked(b"Battery Power\0") };
165/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspoorvalue?language=objc)
166pub const kIOPSPoorValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Poor\0") };
167/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfairvalue?language=objc)
168pub const kIOPSFairValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Fair\0") };
169/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsgoodvalue?language=objc)
170pub const kIOPSGoodValue: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Good\0") };
171/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopscheckbatteryvalue?language=objc)
172pub const kIOPSCheckBatteryValue: &CStr =
173 unsafe { CStr::from_bytes_with_nul_unchecked(b"Check Battery\0") };
174/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopspermanentfailurevalue?language=objc)
175pub const kIOPSPermanentFailureValue: &CStr =
176 unsafe { CStr::from_bytes_with_nul_unchecked(b"Permanent Battery Failure\0") };
177/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailureexternalinput?language=objc)
178pub const kIOPSFailureExternalInput: &CStr =
179 unsafe { CStr::from_bytes_with_nul_unchecked(b"Externally Indicated Failure\0") };
180/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailuresafetyovervoltage?language=objc)
181pub const kIOPSFailureSafetyOverVoltage: &CStr =
182 unsafe { CStr::from_bytes_with_nul_unchecked(b"Safety Over-Voltage\0") };
183/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailurechargeovertemp?language=objc)
184pub const kIOPSFailureChargeOverTemp: &CStr =
185 unsafe { CStr::from_bytes_with_nul_unchecked(b"Charge Over-Temperature\0") };
186/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailuredischargeovertemp?language=objc)
187pub const kIOPSFailureDischargeOverTemp: &CStr =
188 unsafe { CStr::from_bytes_with_nul_unchecked(b"Discharge Over-Temperature\0") };
189/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailurecellimbalance?language=objc)
190pub const kIOPSFailureCellImbalance: &CStr =
191 unsafe { CStr::from_bytes_with_nul_unchecked(b"Cell Imbalance\0") };
192/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailurechargefet?language=objc)
193pub const kIOPSFailureChargeFET: &CStr =
194 unsafe { CStr::from_bytes_with_nul_unchecked(b"Charge FET\0") };
195/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailuredischargefet?language=objc)
196pub const kIOPSFailureDischargeFET: &CStr =
197 unsafe { CStr::from_bytes_with_nul_unchecked(b"Discharge FET\0") };
198/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailuredataflushfault?language=objc)
199pub const kIOPSFailureDataFlushFault: &CStr =
200 unsafe { CStr::from_bytes_with_nul_unchecked(b"Data Flush Fault\0") };
201/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailurepermanentafecomms?language=objc)
202pub const kIOPSFailurePermanentAFEComms: &CStr =
203 unsafe { CStr::from_bytes_with_nul_unchecked(b"Permanent AFE Comms\0") };
204/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailureperiodicafecomms?language=objc)
205pub const kIOPSFailurePeriodicAFEComms: &CStr =
206 unsafe { CStr::from_bytes_with_nul_unchecked(b"Periodic AFE Comms\0") };
207/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailurechargeovercurrent?language=objc)
208pub const kIOPSFailureChargeOverCurrent: &CStr =
209 unsafe { CStr::from_bytes_with_nul_unchecked(b"Charge Over-Current\0") };
210/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailuredischargeovercurrent?language=objc)
211pub const kIOPSFailureDischargeOverCurrent: &CStr =
212 unsafe { CStr::from_bytes_with_nul_unchecked(b"Discharge Over-Current\0") };
213/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailureopenthermistor?language=objc)
214pub const kIOPSFailureOpenThermistor: &CStr =
215 unsafe { CStr::from_bytes_with_nul_unchecked(b"Open Thermistor\0") };
216/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsfailurefuseblown?language=objc)
217pub const kIOPSFailureFuseBlown: &CStr =
218 unsafe { CStr::from_bytes_with_nul_unchecked(b"Fuse Blown\0") };
219/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsnotifylowbattery?language=objc)
220pub const kIOPSNotifyLowBattery: &CStr =
221 unsafe { CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources.lowbattery\0") };
222/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsnotifytimeremaining?language=objc)
223pub const kIOPSNotifyTimeRemaining: &CStr = unsafe {
224 CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources.timeremaining\0")
225};
226/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopstimeremainingnotificationkey?language=objc)
227pub const kIOPSTimeRemainingNotificationKey: &CStr = kIOPSNotifyTimeRemaining;
228/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsnotifypowersource?language=objc)
229pub const kIOPSNotifyPowerSource: &CStr =
230 unsafe { CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources.source\0") };
231/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsnotifyattach?language=objc)
232pub const kIOPSNotifyAttach: &CStr =
233 unsafe { CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources.attach\0") };
234/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopsnotifyanypowersource?language=objc)
235pub const kIOPSNotifyAnyPowerSource: &CStr =
236 unsafe { CStr::from_bytes_with_nul_unchecked(b"com.apple.system.powersources\0") };
237/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopstimeremainingunknown?language=objc)
238pub const kIOPSTimeRemainingUnknown: CFTimeInterval = -1.0;
239/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopstimeremainingunlimited?language=objc)
240pub const kIOPSTimeRemainingUnlimited: CFTimeInterval = -2.0;
241/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopmupspowerkey?language=objc)
242pub const kIOPMUPSPowerKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"UPS Power\0") };
243/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopmbatterypowerkey?language=objc)
244pub const kIOPMBatteryPowerKey: &CStr =
245 unsafe { CStr::from_bytes_with_nul_unchecked(b"Battery Power\0") };
246/// [Apple's documentation](https://developer.apple.com/documentation/iokit/kiopmacpowerkey?language=objc)
247pub const kIOPMACPowerKey: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"AC Power\0") };
248/// Possible return values from
249/// <code>
250///
251/// ```text
252/// IOPSGetBatteryWarningLevel
253/// ```
254///
255/// </code>
256///
257/// See also [Apple's documentation](https://developer.apple.com/documentation/iokit/iopslowbatterywarninglevel?language=objc)
258#[repr(transparent)]
259#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
260pub struct IOPSLowBatteryWarningLevel(pub c_uint);
261impl IOPSLowBatteryWarningLevel {
262 /// The system is not in a low battery situation, or is on drawing from an external power source.
263 ///
264 ///
265 /// The system displays no low power warnings; neither should application clients of this
266 /// API.
267 #[doc(alias = "kIOPSLowBatteryWarningNone")]
268 pub const None: Self = Self(1);
269 /// The battery can provide no more than 20 minutes of runtime.
270 ///
271 ///
272 /// OS X makes no guarantees that the system shall remain in Early Warning for 20 minutes.
273 /// Batteries are frequently calibrated differently and may provide runtime
274 /// for more, or less, than the estimated 20 minutes.
275 /// OS X alerts the user by changing the color of BatteryMonitor to red.
276 /// Warning the user is optional for full screen apps.
277 #[doc(alias = "kIOPSLowBatteryWarningEarly")]
278 pub const Early: Self = Self(2);
279 /// The battery can provide no more than 10 minutes of runtime.
280 ///
281 ///
282 /// OS X makes no guarantees that the system shall remain in Final Warning for 10 minutes.
283 /// Batteries are frequently calibrated differently and may provide runtime
284 /// for more, or less, than the estimated 10 minutes.
285 #[doc(alias = "kIOPSLowBatteryWarningFinal")]
286 pub const Final: Self = Self(3);
287}
288
289#[cfg(feature = "objc2")]
290unsafe impl Encode for IOPSLowBatteryWarningLevel {
291 const ENCODING: Encoding = c_uint::ENCODING;
292}
293
294#[cfg(feature = "objc2")]
295unsafe impl RefEncode for IOPSLowBatteryWarningLevel {
296 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
297}
298
299/// Indicates whether the system is at a low battery warning level.
300///
301///
302/// If your app runs in full screen mode and occludes OS X's battery monitor's low
303/// battery warnings, you should alert the user at least when the system
304/// is in kIOPSLowBatteryWarnFinal.
305#[inline]
306pub extern "C-unwind" fn IOPSGetBatteryWarningLevel() -> IOPSLowBatteryWarningLevel {
307 extern "C-unwind" {
308 fn IOPSGetBatteryWarningLevel() -> IOPSLowBatteryWarningLevel;
309 }
310 unsafe { IOPSGetBatteryWarningLevel() }
311}
312
313/// Returns the estimated minutes remaining until all power sources
314/// (battery and/or UPS's) are empty, or returns
315/// <code>
316///
317/// ```text
318/// kIOPSTimeRemainingUnlimited
319/// ```
320///
321/// </code>
322/// if attached to an unlimited power source.
323///
324///
325/// If attached to an "Unlimited" power source, like AC power or any external source, the
326/// return value is
327/// <code>
328///
329/// ```text
330/// kIOPSTimeRemainingUnlimited
331/// ```
332///
333/// </code>
334///
335/// If the system is on "Limited" power, like a battery or UPS,
336/// but is still calculating the time remaining, which may
337/// take several seconds after each system power event
338/// (e.g. waking from sleep, or unplugging AC Power), the return value is
339/// <code>
340///
341/// ```text
342/// kIOPSTimeRemainingUnknown
343/// ```
344///
345/// </code>
346///
347/// Otherwise, if the system is on "Limited" power and the system has an accurate time
348/// remaining estimate, the system returns a CFTimeInterval estimate of the time
349/// remaining until the system is out of battery power.
350///
351/// If you require more detailed battery information, use
352/// <code>
353///
354/// ```text
355/// IOPSCopyPowerSourcesInfo
356/// ```
357///
358/// >
359/// </code>
360/// and
361/// <code>
362///
363/// ```text
364/// IOPSGetPowerSourceDescription
365/// ```
366///
367/// >
368/// </code>
369/// .
370///
371///
372/// Returns: Returns
373/// <code>
374///
375/// ```text
376/// kIOPSTimeRemainingUnknown
377/// ```
378///
379/// </code>
380/// if the
381/// OS cannot determine the time remaining.
382///
383/// Returns
384/// <code>
385///
386/// ```text
387/// kIOPSTimeRemainingUnlimited
388/// ```
389///
390/// </code>
391/// if the
392/// system has an unlimited power source.
393///
394/// Otherwise returns a positive number of type CFTimeInterval, indicating the time
395/// remaining in seconds until all power sources are depleted.
396#[inline]
397pub extern "C-unwind" fn IOPSGetTimeRemainingEstimate() -> CFTimeInterval {
398 extern "C-unwind" {
399 fn IOPSGetTimeRemainingEstimate() -> CFTimeInterval;
400 }
401 unsafe { IOPSGetTimeRemainingEstimate() }
402}
403
404/// [Apple's documentation](https://developer.apple.com/documentation/iokit/iopowersourcecallbacktype?language=objc)
405pub type IOPowerSourceCallbackType = Option<unsafe extern "C-unwind" fn(*mut c_void)>;
406
407/// Returns a blob of Power Source information in an opaque CFTypeRef.
408///
409///
410/// Clients should not directly access data in the returned CFTypeRef -
411/// they should use the accessor functions IOPSCopyPowerSourcesList and
412/// IOPSGetPowerSourceDescription, instead.
413///
414///
415/// Returns: NULL if errors were encountered, a CFTypeRef otherwise.
416/// Caller must CFRelease() the return value when done accessing it.
417#[inline]
418pub extern "C-unwind" fn IOPSCopyPowerSourcesInfo() -> Option<CFRetained<CFType>> {
419 extern "C-unwind" {
420 fn IOPSCopyPowerSourcesInfo() -> Option<NonNull<CFType>>;
421 }
422 let ret = unsafe { IOPSCopyPowerSourcesInfo() };
423 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
424}
425
426/// Returns a CFArray of Power Source handles, each of type CFTypeRef.
427///
428///
429/// The caller shouldn't directly access the CFTypeRefs, but should use
430/// IOPSGetPowerSourceDescription on each member of the CFArrayRef.
431///
432///
433/// Parameter `blob`: Takes the CFTypeRef returned by IOPSCopyPowerSourcesInfo()
434///
435///
436/// Returns: Returns NULL if errors were encountered, otherwise a CFArray of CFTypeRefs.
437/// Caller must CFRelease() the returned CFArrayRef.
438///
439/// # Safety
440///
441/// - `blob` should be of the correct type.
442/// - `blob` might not allow `None`.
443#[inline]
444pub unsafe extern "C-unwind" fn IOPSCopyPowerSourcesList(
445 blob: Option<&CFType>,
446) -> Option<CFRetained<CFArray>> {
447 extern "C-unwind" {
448 fn IOPSCopyPowerSourcesList(blob: Option<&CFType>) -> Option<NonNull<CFArray>>;
449 }
450 let ret = unsafe { IOPSCopyPowerSourcesList(blob) };
451 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
452}
453
454/// Returns a CFDictionary with readable information about the specific power source.
455///
456///
457/// See the C-strings defined in IOPSKeys.h for specific keys into the dictionary.
458/// Don't expect all keys to be present in any dictionary. Some power sources, for example,
459/// may not support the "Time Remaining To Empty" key and it will not be present in their dictionaries.
460///
461///
462/// Parameter `blob`: The CFTypeRef returned by IOPSCopyPowerSourcesInfo()
463///
464///
465/// Parameter `ps`: One of the CFTypeRefs in the CFArray returned by IOPSCopyPowerSourcesList()
466///
467///
468/// Returns: Returns NULL if an error was encountered, otherwise a CFDictionary. Caller should
469/// NOT release the returned CFDictionary - it will be released as part of the CFTypeRef returned by
470/// IOPSCopyPowerSourcesInfo().
471///
472/// # Safety
473///
474/// - `blob` should be of the correct type.
475/// - `blob` might not allow `None`.
476/// - `ps` should be of the correct type.
477/// - `ps` might not allow `None`.
478#[inline]
479pub unsafe extern "C-unwind" fn IOPSGetPowerSourceDescription(
480 blob: Option<&CFType>,
481 ps: Option<&CFType>,
482) -> Option<CFRetained<CFDictionary>> {
483 extern "C-unwind" {
484 fn IOPSGetPowerSourceDescription(
485 blob: Option<&CFType>,
486 ps: Option<&CFType>,
487 ) -> Option<NonNull<CFDictionary>>;
488 }
489 let ret = unsafe { IOPSGetPowerSourceDescription(blob, ps) };
490 ret.map(|ret| unsafe { CFRetained::retain(ret) })
491}
492
493/// Indicates the power source the computer is currently drawing from.
494///
495///
496/// Determines which power source is providing power.
497///
498///
499/// Parameter `snapshot`: The CFTypeRef returned by IOPSCopyPowerSourcesInfo()
500///
501///
502/// Returns: One of: CFSTR(kIOPMACPowerKey), CFSTR(kIOPMBatteryPowerKey), CFSTR(kIOPMUPSPowerKey)
503///
504/// # Safety
505///
506/// - `snapshot` should be of the correct type.
507/// - `snapshot` might not allow `None`.
508#[inline]
509pub unsafe extern "C-unwind" fn IOPSGetProvidingPowerSourceType(
510 snapshot: Option<&CFType>,
511) -> Option<CFRetained<CFString>> {
512 extern "C-unwind" {
513 fn IOPSGetProvidingPowerSourceType(snapshot: Option<&CFType>) -> Option<NonNull<CFString>>;
514 }
515 let ret = unsafe { IOPSGetProvidingPowerSourceType(snapshot) };
516 ret.map(|ret| unsafe { CFRetained::retain(ret) })
517}
518
519/// Returns a CFRunLoopSourceRef that notifies the caller when power source
520/// information changes.
521///
522///
523/// Returns a CFRunLoopSourceRef for scheduling with your CFRunLoop.
524/// If your project does not use a CFRunLoop, you can alternatively
525/// receive notifications via mach port, dispatch, or signal, via
526/// <code>
527/// notify.h
528/// </code>
529/// using the name
530/// <code>
531///
532/// ```text
533/// kIOPSTimeRemainingNotificationKey
534/// ```
535///
536/// </code>
537/// .
538///
539/// IOKit delivers this notification when percent remaining or time remaining changes.
540/// Thus it fires fairly frequently while discharging or charging the battery;
541/// please consider using:
542/// <code>
543///
544/// ```text
545/// IOPSCreateLimitedPowerNotification
546/// ```
547///
548/// </code>
549/// if you only require
550/// notifications when the power source type changes from limited to unlimited.
551///
552///
553/// Parameter `callback`: A function to be called whenever any power source is added, removed, or changes.
554///
555///
556/// Parameter `context`: Any user-defined pointer, passed to the IOPowerSource callback.
557///
558///
559/// Returns: Returns NULL if an error was encountered, otherwise a CFRunLoopSource. Caller must
560/// release the CFRunLoopSource.
561///
562/// # Safety
563///
564/// - `callback` must be implemented correctly.
565/// - `context` must be a valid pointer.
566#[inline]
567pub unsafe extern "C-unwind" fn IOPSNotificationCreateRunLoopSource(
568 callback: IOPowerSourceCallbackType,
569 context: *mut c_void,
570) -> Option<CFRetained<CFRunLoopSource>> {
571 extern "C-unwind" {
572 fn IOPSNotificationCreateRunLoopSource(
573 callback: IOPowerSourceCallbackType,
574 context: *mut c_void,
575 ) -> Option<NonNull<CFRunLoopSource>>;
576 }
577 let ret = unsafe { IOPSNotificationCreateRunLoopSource(callback, context) };
578 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
579}
580
581/// Returns a CFRunLoopSourceRef that notifies the caller when power source
582/// changes from an unlimited power source (like attached to wall, car, or airplane power), to a limited
583/// power source (like a battery or UPS).
584///
585///
586/// Returns a CFRunLoopSourceRef for scheduling with your CFRunLoop.
587/// If your project does not use a CFRunLoop, you can alternatively
588/// receive this notification via
589/// <code>
590/// notify.h
591/// </code>
592/// using the name
593/// <code>
594///
595/// ```text
596/// kIOPSNotifyPowerSource
597/// ```
598///
599/// </code>
600///
601///
602/// Parameter `callback`: A function to be called whenever the power source changes from AC to DC..
603///
604///
605/// Parameter `context`: Any user-defined pointer, passed to the IOPowerSource callback.
606///
607///
608/// Returns: Returns NULL if an error was encountered, otherwise a CFRunLoopSource. Caller must
609/// release the CFRunLoopSource.
610///
611/// # Safety
612///
613/// - `callback` must be implemented correctly.
614/// - `context` must be a valid pointer.
615#[inline]
616pub unsafe extern "C-unwind" fn IOPSCreateLimitedPowerNotification(
617 callback: IOPowerSourceCallbackType,
618 context: *mut c_void,
619) -> Option<CFRetained<CFRunLoopSource>> {
620 extern "C-unwind" {
621 fn IOPSCreateLimitedPowerNotification(
622 callback: IOPowerSourceCallbackType,
623 context: *mut c_void,
624 ) -> Option<NonNull<CFRunLoopSource>>;
625 }
626 let ret = unsafe { IOPSCreateLimitedPowerNotification(callback, context) };
627 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
628}
629
630/// Returns a CFDictionary that describes the attached (AC) external
631/// power adapter (if any external power adapter is attached.
632///
633///
634/// Use the kIOPSPowerAdapter... keys described in IOPSKeys.h
635/// to interpret the returned CFDictionary.
636///
637///
638/// Returns: Returns a CFDictionary on success. Caller must release the returned
639/// dictionary. If no adapter is attached, or if there's an error, returns NULL.
640#[inline]
641pub extern "C-unwind" fn IOPSCopyExternalPowerAdapterDetails() -> Option<CFRetained<CFDictionary>> {
642 extern "C-unwind" {
643 fn IOPSCopyExternalPowerAdapterDetails() -> Option<NonNull<CFDictionary>>;
644 }
645 let ret = unsafe { IOPSCopyExternalPowerAdapterDetails() };
646 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
647}
648
649/// Type and arguments of callout C function that is used when a
650/// completion routine is called. This function pointer is set
651/// via setEventCallback and is called when an event is available
652/// from the UPS.
653///
654/// Parameter `target`: void * pointer to your data, often a pointer to an object.
655///
656/// Parameter `result`: Completion result of desired operation.
657///
658/// Parameter `refcon`: void * pointer to more data.
659///
660/// Parameter `sender`: Interface instance sending the completion routine.
661///
662/// Parameter `event`: CFDictionaryRef containing event data.
663///
664/// See also [Apple's documentation](https://developer.apple.com/documentation/iokit/ioupseventcallbackfunction?language=objc)
665pub type IOUPSEventCallbackFunction = Option<
666 unsafe extern "C-unwind" fn(
667 *mut c_void,
668 IOReturn,
669 *mut c_void,
670 *mut c_void,
671 *const CFDictionary,
672 ),
673>;
674
675/// [Apple's documentation](https://developer.apple.com/documentation/iokit/ioupsplugininterface?language=objc)
676#[repr(C)]
677#[allow(unpredictable_function_pointer_comparisons)]
678#[derive(Clone, Copy, Debug, PartialEq)]
679pub struct IOUPSPlugInInterface {
680 pub(crate) _reserved: *mut c_void,
681 pub QueryInterface:
682 Option<unsafe extern "C-unwind" fn(*mut c_void, REFIID, *mut LPVOID) -> HRESULT>,
683 pub AddRef: Option<unsafe extern "C-unwind" fn(*mut c_void) -> ULONG>,
684 pub Release: Option<unsafe extern "C-unwind" fn(*mut c_void) -> ULONG>,
685 pub getProperties:
686 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFDictionary) -> IOReturn>,
687 pub getCapabilities:
688 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFSet) -> IOReturn>,
689 pub getEvent:
690 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFDictionary) -> IOReturn>,
691 pub setEventCallback: Option<
692 unsafe extern "C-unwind" fn(
693 *mut c_void,
694 IOUPSEventCallbackFunction,
695 *mut c_void,
696 *mut c_void,
697 ) -> IOReturn,
698 >,
699 pub sendCommand:
700 Option<unsafe extern "C-unwind" fn(*mut c_void, *const CFDictionary) -> IOReturn>,
701}
702
703#[cfg(feature = "objc2")]
704unsafe impl Encode for IOUPSPlugInInterface {
705 const ENCODING: Encoding = Encoding::Struct("IOUPSPlugInInterface", &[
706 <*mut c_void>::ENCODING,
707 <Option<unsafe extern "C-unwind" fn(*mut c_void,REFIID,*mut LPVOID,) -> HRESULT>>::ENCODING,
708 <Option<unsafe extern "C-unwind" fn(*mut c_void,) -> ULONG>>::ENCODING,
709 <Option<unsafe extern "C-unwind" fn(*mut c_void,) -> ULONG>>::ENCODING,
710 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFDictionary,) -> IOReturn>>::ENCODING,
711 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFSet,) -> IOReturn>>::ENCODING,
712 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFDictionary,) -> IOReturn>>::ENCODING,
713 <Option<unsafe extern "C-unwind" fn(*mut c_void,IOUPSEventCallbackFunction,*mut c_void,*mut c_void,) -> IOReturn>>::ENCODING,
714 <Option<unsafe extern "C-unwind" fn(*mut c_void,*const CFDictionary,) -> IOReturn>>::ENCODING,
715 ]);
716}
717
718#[cfg(feature = "objc2")]
719unsafe impl RefEncode for IOUPSPlugInInterface {
720 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
721}
722
723/// [Apple's documentation](https://developer.apple.com/documentation/iokit/ioupsplugininterface_v140?language=objc)
724#[repr(C)]
725#[allow(unpredictable_function_pointer_comparisons)]
726#[derive(Clone, Copy, Debug, PartialEq)]
727pub struct IOUPSPlugInInterface_v140 {
728 pub(crate) _reserved: *mut c_void,
729 pub QueryInterface:
730 Option<unsafe extern "C-unwind" fn(*mut c_void, REFIID, *mut LPVOID) -> HRESULT>,
731 pub AddRef: Option<unsafe extern "C-unwind" fn(*mut c_void) -> ULONG>,
732 pub Release: Option<unsafe extern "C-unwind" fn(*mut c_void) -> ULONG>,
733 pub getProperties:
734 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFDictionary) -> IOReturn>,
735 pub getCapabilities:
736 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFSet) -> IOReturn>,
737 pub getEvent:
738 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFDictionary) -> IOReturn>,
739 pub setEventCallback: Option<
740 unsafe extern "C-unwind" fn(
741 *mut c_void,
742 IOUPSEventCallbackFunction,
743 *mut c_void,
744 *mut c_void,
745 ) -> IOReturn,
746 >,
747 pub sendCommand:
748 Option<unsafe extern "C-unwind" fn(*mut c_void, *const CFDictionary) -> IOReturn>,
749 pub createAsyncEventSource:
750 Option<unsafe extern "C-unwind" fn(*mut c_void, *mut *const CFType) -> IOReturn>,
751}
752
753#[cfg(feature = "objc2")]
754unsafe impl Encode for IOUPSPlugInInterface_v140 {
755 const ENCODING: Encoding = Encoding::Struct("IOUPSPlugInInterface_v140", &[
756 <*mut c_void>::ENCODING,
757 <Option<unsafe extern "C-unwind" fn(*mut c_void,REFIID,*mut LPVOID,) -> HRESULT>>::ENCODING,
758 <Option<unsafe extern "C-unwind" fn(*mut c_void,) -> ULONG>>::ENCODING,
759 <Option<unsafe extern "C-unwind" fn(*mut c_void,) -> ULONG>>::ENCODING,
760 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFDictionary,) -> IOReturn>>::ENCODING,
761 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFSet,) -> IOReturn>>::ENCODING,
762 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFDictionary,) -> IOReturn>>::ENCODING,
763 <Option<unsafe extern "C-unwind" fn(*mut c_void,IOUPSEventCallbackFunction,*mut c_void,*mut c_void,) -> IOReturn>>::ENCODING,
764 <Option<unsafe extern "C-unwind" fn(*mut c_void,*const CFDictionary,) -> IOReturn>>::ENCODING,
765 <Option<unsafe extern "C-unwind" fn(*mut c_void,*mut *const CFType,) -> IOReturn>>::ENCODING,
766 ]);
767}
768
769#[cfg(feature = "objc2")]
770unsafe impl RefEncode for IOUPSPlugInInterface_v140 {
771 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
772}