objc2_foundation/generated/
NSProcessInfo.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindowsntoperatingsystem?language=objc)
10#[deprecated = "Not supported"]
11pub const NSWindowsNTOperatingSystem: c_uint = 1;
12/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswindows95operatingsystem?language=objc)
13#[deprecated = "Not supported"]
14pub const NSWindows95OperatingSystem: c_uint = 2;
15/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssolarisoperatingsystem?language=objc)
16#[deprecated = "Not supported"]
17pub const NSSolarisOperatingSystem: c_uint = 3;
18/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nshpuxoperatingsystem?language=objc)
19#[deprecated = "Not supported"]
20pub const NSHPUXOperatingSystem: c_uint = 4;
21/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmachoperatingsystem?language=objc)
22#[deprecated = "Not supported"]
23pub const NSMACHOperatingSystem: c_uint = 5;
24/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssunosoperatingsystem?language=objc)
25#[deprecated = "Not supported"]
26pub const NSSunOSOperatingSystem: c_uint = 6;
27/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsosf1operatingsystem?language=objc)
28#[deprecated = "Not supported"]
29pub const NSOSF1OperatingSystem: c_uint = 7;
30
31/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsoperatingsystemversion?language=objc)
32#[repr(C)]
33#[derive(Clone, Copy, Debug, PartialEq)]
34pub struct NSOperatingSystemVersion {
35    pub majorVersion: NSInteger,
36    pub minorVersion: NSInteger,
37    pub patchVersion: NSInteger,
38}
39
40unsafe impl Encode for NSOperatingSystemVersion {
41    const ENCODING: Encoding = Encoding::Struct(
42        "?",
43        &[
44            <NSInteger>::ENCODING,
45            <NSInteger>::ENCODING,
46            <NSInteger>::ENCODING,
47        ],
48    );
49}
50
51unsafe impl RefEncode for NSOperatingSystemVersion {
52    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55unsafe impl Send for NSOperatingSystemVersion {}
56
57unsafe impl Sync for NSOperatingSystemVersion {}
58
59extern_class!(
60    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprocessinfo?language=objc)
61    #[unsafe(super(NSObject))]
62    #[derive(PartialEq, Eq, Hash)]
63    pub struct NSProcessInfo;
64);
65
66unsafe impl Send for NSProcessInfo {}
67
68unsafe impl Sync for NSProcessInfo {}
69
70extern_conformance!(
71    unsafe impl NSObjectProtocol for NSProcessInfo {}
72);
73
74impl NSProcessInfo {
75    extern_methods!(
76        #[unsafe(method(processInfo))]
77        #[unsafe(method_family = none)]
78        pub fn processInfo() -> Retained<NSProcessInfo>;
79
80        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
81        #[unsafe(method(environment))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn environment(&self) -> Retained<NSDictionary<NSString, NSString>>;
84
85        #[cfg(all(feature = "NSArray", feature = "NSString"))]
86        #[unsafe(method(arguments))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn arguments(&self) -> Retained<NSArray<NSString>>;
89
90        #[cfg(feature = "NSString")]
91        #[unsafe(method(hostName))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn hostName(&self) -> Retained<NSString>;
94
95        #[cfg(feature = "NSString")]
96        #[unsafe(method(processName))]
97        #[unsafe(method_family = none)]
98        pub fn processName(&self) -> Retained<NSString>;
99
100        #[cfg(feature = "NSString")]
101        /// Setter for [`processName`][Self::processName].
102        #[unsafe(method(setProcessName:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn setProcessName(&self, process_name: &NSString);
105
106        #[unsafe(method(processIdentifier))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn processIdentifier(&self) -> c_int;
109
110        #[cfg(feature = "NSString")]
111        #[unsafe(method(globallyUniqueString))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn globallyUniqueString(&self) -> Retained<NSString>;
114
115        #[deprecated = "-operatingSystem always returns NSMACHOperatingSystem, use -operatingSystemVersion or -isOperatingSystemAtLeastVersion: instead"]
116        #[unsafe(method(operatingSystem))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn operatingSystem(&self) -> NSUInteger;
119
120        #[cfg(feature = "NSString")]
121        #[deprecated = "-operatingSystemName always returns NSMACHOperatingSystem, use -operatingSystemVersionString instead"]
122        #[unsafe(method(operatingSystemName))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn operatingSystemName(&self) -> Retained<NSString>;
125
126        #[cfg(feature = "NSString")]
127        #[unsafe(method(operatingSystemVersionString))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn operatingSystemVersionString(&self) -> Retained<NSString>;
130
131        #[unsafe(method(operatingSystemVersion))]
132        #[unsafe(method_family = none)]
133        pub fn operatingSystemVersion(&self) -> NSOperatingSystemVersion;
134
135        #[unsafe(method(processorCount))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn processorCount(&self) -> NSUInteger;
138
139        #[unsafe(method(activeProcessorCount))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn activeProcessorCount(&self) -> NSUInteger;
142
143        #[unsafe(method(physicalMemory))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn physicalMemory(&self) -> c_ulonglong;
146
147        #[unsafe(method(isOperatingSystemAtLeastVersion:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn isOperatingSystemAtLeastVersion(
150            &self,
151            version: NSOperatingSystemVersion,
152        ) -> bool;
153
154        #[cfg(feature = "NSDate")]
155        #[unsafe(method(systemUptime))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn systemUptime(&self) -> NSTimeInterval;
158
159        #[unsafe(method(disableSuddenTermination))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn disableSuddenTermination(&self);
162
163        #[unsafe(method(enableSuddenTermination))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn enableSuddenTermination(&self);
166
167        #[cfg(feature = "NSString")]
168        #[unsafe(method(disableAutomaticTermination:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn disableAutomaticTermination(&self, reason: &NSString);
171
172        #[cfg(feature = "NSString")]
173        #[unsafe(method(enableAutomaticTermination:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn enableAutomaticTermination(&self, reason: &NSString);
176
177        #[unsafe(method(automaticTerminationSupportEnabled))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn automaticTerminationSupportEnabled(&self) -> bool;
180
181        /// Setter for [`automaticTerminationSupportEnabled`][Self::automaticTerminationSupportEnabled].
182        #[unsafe(method(setAutomaticTerminationSupportEnabled:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn setAutomaticTerminationSupportEnabled(
185            &self,
186            automatic_termination_support_enabled: bool,
187        );
188    );
189}
190
191/// Methods declared on superclass `NSObject`.
192impl NSProcessInfo {
193    extern_methods!(
194        #[unsafe(method(init))]
195        #[unsafe(method_family = init)]
196        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
197
198        #[unsafe(method(new))]
199        #[unsafe(method_family = new)]
200        pub unsafe fn new() -> Retained<Self>;
201    );
202}
203
204/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsactivityoptions?language=objc)
205// NS_OPTIONS
206#[repr(transparent)]
207#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
208pub struct NSActivityOptions(pub u64);
209bitflags::bitflags! {
210    impl NSActivityOptions: u64 {
211        #[doc(alias = "NSActivityIdleDisplaySleepDisabled")]
212        const IdleDisplaySleepDisabled = 1<<40;
213        #[doc(alias = "NSActivityIdleSystemSleepDisabled")]
214        const IdleSystemSleepDisabled = 1<<20;
215        #[doc(alias = "NSActivitySuddenTerminationDisabled")]
216        const SuddenTerminationDisabled = 1<<14;
217        #[doc(alias = "NSActivityAutomaticTerminationDisabled")]
218        const AutomaticTerminationDisabled = 1<<15;
219        #[doc(alias = "NSActivityAnimationTrackingEnabled")]
220        const AnimationTrackingEnabled = 1<<45;
221        #[doc(alias = "NSActivityTrackingEnabled")]
222        const TrackingEnabled = 1<<46;
223        #[doc(alias = "NSActivityUserInitiated")]
224        const UserInitiated = 0x00FFFFFF|NSActivityOptions::IdleSystemSleepDisabled.0;
225        #[doc(alias = "NSActivityUserInitiatedAllowingIdleSystemSleep")]
226        const UserInitiatedAllowingIdleSystemSleep = NSActivityOptions::UserInitiated.0&!NSActivityOptions::IdleSystemSleepDisabled.0;
227        #[doc(alias = "NSActivityBackground")]
228        const Background = 0x000000FF;
229        #[doc(alias = "NSActivityLatencyCritical")]
230        const LatencyCritical = 0xFF00000000;
231        #[doc(alias = "NSActivityUserInteractive")]
232        const UserInteractive = NSActivityOptions::UserInitiated.0|NSActivityOptions::LatencyCritical.0;
233    }
234}
235
236unsafe impl Encode for NSActivityOptions {
237    const ENCODING: Encoding = u64::ENCODING;
238}
239
240unsafe impl RefEncode for NSActivityOptions {
241    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
242}
243
244/// NSProcessInfoActivity.
245impl NSProcessInfo {
246    extern_methods!(
247        #[cfg(feature = "NSString")]
248        #[unsafe(method(beginActivityWithOptions:reason:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn beginActivityWithOptions_reason(
251            &self,
252            options: NSActivityOptions,
253            reason: &NSString,
254        ) -> Retained<ProtocolObject<dyn NSObjectProtocol>>;
255
256        #[unsafe(method(endActivity:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn endActivity(&self, activity: &ProtocolObject<dyn NSObjectProtocol>);
259
260        #[cfg(all(feature = "NSString", feature = "block2"))]
261        #[unsafe(method(performActivityWithOptions:reason:usingBlock:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn performActivityWithOptions_reason_usingBlock(
264            &self,
265            options: NSActivityOptions,
266            reason: &NSString,
267            block: &block2::DynBlock<dyn Fn()>,
268        );
269
270        #[cfg(all(feature = "NSString", feature = "block2"))]
271        #[unsafe(method(performExpiringActivityWithReason:usingBlock:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn performExpiringActivityWithReason_usingBlock(
274            &self,
275            reason: &NSString,
276            block: &block2::DynBlock<dyn Fn(Bool)>,
277        );
278    );
279}
280
281/// NSUserInformation.
282impl NSProcessInfo {
283    extern_methods!(
284        #[cfg(feature = "NSString")]
285        #[unsafe(method(userName))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn userName(&self) -> Retained<NSString>;
288
289        #[cfg(feature = "NSString")]
290        #[unsafe(method(fullUserName))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn fullUserName(&self) -> Retained<NSString>;
293    );
294}
295
296/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprocessinfothermalstate?language=objc)
297// NS_ENUM
298#[repr(transparent)]
299#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
300pub struct NSProcessInfoThermalState(pub NSInteger);
301impl NSProcessInfoThermalState {
302    #[doc(alias = "NSProcessInfoThermalStateNominal")]
303    pub const Nominal: Self = Self(0);
304    #[doc(alias = "NSProcessInfoThermalStateFair")]
305    pub const Fair: Self = Self(1);
306    #[doc(alias = "NSProcessInfoThermalStateSerious")]
307    pub const Serious: Self = Self(2);
308    #[doc(alias = "NSProcessInfoThermalStateCritical")]
309    pub const Critical: Self = Self(3);
310}
311
312unsafe impl Encode for NSProcessInfoThermalState {
313    const ENCODING: Encoding = NSInteger::ENCODING;
314}
315
316unsafe impl RefEncode for NSProcessInfoThermalState {
317    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
318}
319
320/// NSProcessInfoThermalState.
321impl NSProcessInfo {
322    extern_methods!(
323        #[unsafe(method(thermalState))]
324        #[unsafe(method_family = none)]
325        pub unsafe fn thermalState(&self) -> NSProcessInfoThermalState;
326    );
327}
328
329/// NSProcessInfoPowerState.
330impl NSProcessInfo {
331    extern_methods!(
332        #[unsafe(method(isLowPowerModeEnabled))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn isLowPowerModeEnabled(&self) -> bool;
335    );
336}
337
338extern "C" {
339    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprocessinfothermalstatedidchangenotification?language=objc)
340    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
341    pub static NSProcessInfoThermalStateDidChangeNotification: &'static NSNotificationName;
342}
343
344extern "C" {
345    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprocessinfopowerstatedidchangenotification?language=objc)
346    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
347    pub static NSProcessInfoPowerStateDidChangeNotification: &'static NSNotificationName;
348}
349
350/// NSProcessInfoPlatform.
351impl NSProcessInfo {
352    extern_methods!(
353        #[unsafe(method(isMacCatalystApp))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn isMacCatalystApp(&self) -> bool;
356
357        #[unsafe(method(isiOSAppOnMac))]
358        #[unsafe(method_family = none)]
359        pub unsafe fn isiOSAppOnMac(&self) -> bool;
360    );
361}