icrate/generated/Foundation/
NSProcessInfo.rs1use crate::common::*;
4use crate::Foundation::*;
5
6extern_enum!(
7 #[underlying(c_uint)]
8 #[deprecated = "Not supported"]
9 pub enum __anonymous__ {
10 #[deprecated = "Not supported"]
11 NSWindowsNTOperatingSystem = 1,
12 #[deprecated = "Not supported"]
13 NSWindows95OperatingSystem = 2,
14 #[deprecated = "Not supported"]
15 NSSolarisOperatingSystem = 3,
16 #[deprecated = "Not supported"]
17 NSHPUXOperatingSystem = 4,
18 #[deprecated = "Not supported"]
19 NSMACHOperatingSystem = 5,
20 #[deprecated = "Not supported"]
21 NSSunOSOperatingSystem = 6,
22 #[deprecated = "Not supported"]
23 NSOSF1OperatingSystem = 7,
24 }
25);
26
27extern_struct!(
28 #[encoding_name("?")]
29 pub struct NSOperatingSystemVersion {
30 pub majorVersion: NSInteger,
31 pub minorVersion: NSInteger,
32 pub patchVersion: NSInteger,
33 }
34);
35
36unsafe impl Send for NSOperatingSystemVersion {}
37
38unsafe impl Sync for NSOperatingSystemVersion {}
39
40extern_class!(
41 #[derive(PartialEq, Eq, Hash)]
42 #[cfg(feature = "Foundation_NSProcessInfo")]
43 pub struct NSProcessInfo;
44
45 #[cfg(feature = "Foundation_NSProcessInfo")]
46 unsafe impl ClassType for NSProcessInfo {
47 type Super = NSObject;
48 type Mutability = InteriorMutable;
49 }
50);
51
52#[cfg(feature = "Foundation_NSProcessInfo")]
53unsafe impl NSObjectProtocol for NSProcessInfo {}
54
55extern_methods!(
56 #[cfg(feature = "Foundation_NSProcessInfo")]
57 unsafe impl NSProcessInfo {
58 #[method_id(@__retain_semantics Other processInfo)]
59 pub fn processInfo() -> Id<NSProcessInfo>;
60
61 #[cfg(all(feature = "Foundation_NSDictionary", feature = "Foundation_NSString"))]
62 #[method_id(@__retain_semantics Other environment)]
63 pub unsafe fn environment(&self) -> Id<NSDictionary<NSString, NSString>>;
64
65 #[cfg(all(feature = "Foundation_NSArray", feature = "Foundation_NSString"))]
66 #[method_id(@__retain_semantics Other arguments)]
67 pub unsafe fn arguments(&self) -> Id<NSArray<NSString>>;
68
69 #[cfg(feature = "Foundation_NSString")]
70 #[method_id(@__retain_semantics Other hostName)]
71 pub unsafe fn hostName(&self) -> Id<NSString>;
72
73 #[cfg(feature = "Foundation_NSString")]
74 #[method_id(@__retain_semantics Other processName)]
75 pub fn processName(&self) -> Id<NSString>;
76
77 #[cfg(feature = "Foundation_NSString")]
78 #[method(setProcessName:)]
79 pub unsafe fn setProcessName(&self, process_name: &NSString);
80
81 #[method(processIdentifier)]
82 pub unsafe fn processIdentifier(&self) -> c_int;
83
84 #[cfg(feature = "Foundation_NSString")]
85 #[method_id(@__retain_semantics Other globallyUniqueString)]
86 pub unsafe fn globallyUniqueString(&self) -> Id<NSString>;
87
88 #[deprecated = "-operatingSystem always returns NSMACHOperatingSystem, use -operatingSystemVersion or -isOperatingSystemAtLeastVersion: instead"]
89 #[method(operatingSystem)]
90 pub unsafe fn operatingSystem(&self) -> NSUInteger;
91
92 #[cfg(feature = "Foundation_NSString")]
93 #[deprecated = "-operatingSystemName always returns NSMACHOperatingSystem, use -operatingSystemVersionString instead"]
94 #[method_id(@__retain_semantics Other operatingSystemName)]
95 pub unsafe fn operatingSystemName(&self) -> Id<NSString>;
96
97 #[cfg(feature = "Foundation_NSString")]
98 #[method_id(@__retain_semantics Other operatingSystemVersionString)]
99 pub unsafe fn operatingSystemVersionString(&self) -> Id<NSString>;
100
101 #[method(operatingSystemVersion)]
102 pub fn operatingSystemVersion(&self) -> NSOperatingSystemVersion;
103
104 #[method(processorCount)]
105 pub unsafe fn processorCount(&self) -> NSUInteger;
106
107 #[method(activeProcessorCount)]
108 pub unsafe fn activeProcessorCount(&self) -> NSUInteger;
109
110 #[method(physicalMemory)]
111 pub unsafe fn physicalMemory(&self) -> c_ulonglong;
112
113 #[method(isOperatingSystemAtLeastVersion:)]
114 pub unsafe fn isOperatingSystemAtLeastVersion(
115 &self,
116 version: NSOperatingSystemVersion,
117 ) -> bool;
118
119 #[method(systemUptime)]
120 pub unsafe fn systemUptime(&self) -> NSTimeInterval;
121
122 #[method(disableSuddenTermination)]
123 pub unsafe fn disableSuddenTermination(&self);
124
125 #[method(enableSuddenTermination)]
126 pub unsafe fn enableSuddenTermination(&self);
127
128 #[cfg(feature = "Foundation_NSString")]
129 #[method(disableAutomaticTermination:)]
130 pub unsafe fn disableAutomaticTermination(&self, reason: &NSString);
131
132 #[cfg(feature = "Foundation_NSString")]
133 #[method(enableAutomaticTermination:)]
134 pub unsafe fn enableAutomaticTermination(&self, reason: &NSString);
135
136 #[method(automaticTerminationSupportEnabled)]
137 pub unsafe fn automaticTerminationSupportEnabled(&self) -> bool;
138
139 #[method(setAutomaticTerminationSupportEnabled:)]
140 pub unsafe fn setAutomaticTerminationSupportEnabled(
141 &self,
142 automatic_termination_support_enabled: bool,
143 );
144 }
145);
146
147extern_methods!(
148 #[cfg(feature = "Foundation_NSProcessInfo")]
150 unsafe impl NSProcessInfo {
151 #[method_id(@__retain_semantics Init init)]
152 pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
153
154 #[method_id(@__retain_semantics New new)]
155 pub unsafe fn new() -> Id<Self>;
156 }
157);
158
159ns_options!(
160 #[underlying(u64)]
161 pub enum NSActivityOptions {
162 NSActivityIdleDisplaySleepDisabled = 1 << 40,
163 NSActivityIdleSystemSleepDisabled = 1 << 20,
164 NSActivitySuddenTerminationDisabled = 1 << 14,
165 NSActivityAutomaticTerminationDisabled = 1 << 15,
166 NSActivityAnimationTrackingEnabled = 1 << 45,
167 NSActivityTrackingEnabled = 1 << 46,
168 NSActivityUserInitiated = 0x00FFFFFF | NSActivityIdleSystemSleepDisabled,
169 NSActivityUserInitiatedAllowingIdleSystemSleep =
170 NSActivityUserInitiated & !NSActivityIdleSystemSleepDisabled,
171 NSActivityBackground = 0x000000FF,
172 NSActivityLatencyCritical = 0xFF00000000,
173 NSActivityUserInteractive = NSActivityUserInitiated | NSActivityLatencyCritical,
174 }
175);
176
177extern_methods!(
178 #[cfg(feature = "Foundation_NSProcessInfo")]
180 unsafe impl NSProcessInfo {
181 #[cfg(feature = "Foundation_NSString")]
182 #[method_id(@__retain_semantics Other beginActivityWithOptions:reason:)]
183 pub unsafe fn beginActivityWithOptions_reason(
184 &self,
185 options: NSActivityOptions,
186 reason: &NSString,
187 ) -> Id<NSObject>;
188
189 #[method(endActivity:)]
190 pub unsafe fn endActivity(&self, activity: &NSObject);
191
192 #[cfg(feature = "Foundation_NSString")]
193 #[method(performActivityWithOptions:reason:usingBlock:)]
194 pub unsafe fn performActivityWithOptions_reason_usingBlock(
195 &self,
196 options: NSActivityOptions,
197 reason: &NSString,
198 block: &Block<(), ()>,
199 );
200
201 #[cfg(feature = "Foundation_NSString")]
202 #[method(performExpiringActivityWithReason:usingBlock:)]
203 pub unsafe fn performExpiringActivityWithReason_usingBlock(
204 &self,
205 reason: &NSString,
206 block: &Block<(Bool,), ()>,
207 );
208 }
209);
210
211extern_methods!(
212 #[cfg(feature = "Foundation_NSProcessInfo")]
214 unsafe impl NSProcessInfo {
215 #[cfg(feature = "Foundation_NSString")]
216 #[method_id(@__retain_semantics Other userName)]
217 pub unsafe fn userName(&self) -> Id<NSString>;
218
219 #[cfg(feature = "Foundation_NSString")]
220 #[method_id(@__retain_semantics Other fullUserName)]
221 pub unsafe fn fullUserName(&self) -> Id<NSString>;
222 }
223);
224
225ns_enum!(
226 #[underlying(NSInteger)]
227 pub enum NSProcessInfoThermalState {
228 NSProcessInfoThermalStateNominal = 0,
229 NSProcessInfoThermalStateFair = 1,
230 NSProcessInfoThermalStateSerious = 2,
231 NSProcessInfoThermalStateCritical = 3,
232 }
233);
234
235extern_methods!(
236 #[cfg(feature = "Foundation_NSProcessInfo")]
238 unsafe impl NSProcessInfo {
239 #[method(thermalState)]
240 pub unsafe fn thermalState(&self) -> NSProcessInfoThermalState;
241 }
242);
243
244extern_methods!(
245 #[cfg(feature = "Foundation_NSProcessInfo")]
247 unsafe impl NSProcessInfo {
248 #[method(isLowPowerModeEnabled)]
249 pub unsafe fn isLowPowerModeEnabled(&self) -> bool;
250 }
251);
252
253extern_static!(NSProcessInfoThermalStateDidChangeNotification: &'static NSNotificationName);
254
255extern_static!(NSProcessInfoPowerStateDidChangeNotification: &'static NSNotificationName);
256
257extern_methods!(
258 #[cfg(feature = "Foundation_NSProcessInfo")]
260 unsafe impl NSProcessInfo {
261 #[method(isMacCatalystApp)]
262 pub unsafe fn isMacCatalystApp(&self) -> bool;
263
264 #[method(isiOSAppOnMac)]
265 pub unsafe fn isiOSAppOnMac(&self) -> bool;
266 }
267);