objc2_cloud_kit/generated/CKOperation.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckoperationid?language=objc)
11pub type CKOperationID = NSString;
12
13extern_class!(
14 /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckoperation?language=objc)
15 #[unsafe(super(NSOperation, NSObject))]
16 #[derive(Debug, PartialEq, Eq, Hash)]
17 pub struct CKOperation;
18);
19
20extern_conformance!(
21 unsafe impl NSObjectProtocol for CKOperation {}
22);
23
24impl CKOperation {
25 extern_methods!(
26 #[unsafe(method(init))]
27 #[unsafe(method_family = init)]
28 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
29
30 /// This defines per-operation configuration settings.
31 ///
32 ///
33 /// See the CKOperationConfiguration class description for info on how this configuration composes with CKOperationGroup.defaultConfiguration
34 ///
35 /// This property is not atomic.
36 ///
37 /// # Safety
38 ///
39 /// This might not be thread-safe.
40 #[unsafe(method(configuration))]
41 #[unsafe(method_family = none)]
42 pub unsafe fn configuration(&self) -> Retained<CKOperationConfiguration>;
43
44 /// Setter for [`configuration`][Self::configuration].
45 ///
46 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
47 ///
48 /// # Safety
49 ///
50 /// This might not be thread-safe.
51 #[unsafe(method(setConfiguration:))]
52 #[unsafe(method_family = none)]
53 pub unsafe fn setConfiguration(&self, configuration: Option<&CKOperationConfiguration>);
54
55 #[cfg(feature = "CKOperationGroup")]
56 /// The group this operation is associated with
57 ///
58 /// This property is not atomic.
59 ///
60 /// # Safety
61 ///
62 /// This might not be thread-safe.
63 #[unsafe(method(group))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn group(&self) -> Option<Retained<CKOperationGroup>>;
66
67 #[cfg(feature = "CKOperationGroup")]
68 /// Setter for [`group`][Self::group].
69 ///
70 /// # Safety
71 ///
72 /// This might not be thread-safe.
73 #[unsafe(method(setGroup:))]
74 #[unsafe(method_family = none)]
75 pub unsafe fn setGroup(&self, group: Option<&CKOperationGroup>);
76
77 /// This is an identifier unique to this CKOperation.
78 ///
79 ///
80 /// This value is chosen by the system, and will be unique to this instance of a CKOperation. This identifier will be sent to Apple's servers, and can be used to identify any server-side logging associated with this operation.
81 ///
82 /// This property is not atomic.
83 ///
84 /// # Safety
85 ///
86 /// This might not be thread-safe.
87 #[unsafe(method(operationID))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn operationID(&self) -> Retained<CKOperationID>;
90
91 #[cfg(feature = "block2")]
92 /// This callback is called after a long lived operation has begun running and is persisted.
93 ///
94 ///
95 /// Once this callback is called the operation will continue running even if the current process exits.
96 /// Each
97 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
98 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
99 /// should not be concurrently used outside of blocks assigned to this operation.
100 ///
101 /// This property is not atomic.
102 ///
103 /// # Safety
104 ///
105 /// This might not be thread-safe.
106 #[unsafe(method(longLivedOperationWasPersistedBlock))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn longLivedOperationWasPersistedBlock(&self)
109 -> *mut block2::DynBlock<dyn Fn()>;
110
111 #[cfg(feature = "block2")]
112 /// Setter for [`longLivedOperationWasPersistedBlock`][Self::longLivedOperationWasPersistedBlock].
113 ///
114 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
115 ///
116 /// # Safety
117 ///
118 /// This might not be thread-safe.
119 #[unsafe(method(setLongLivedOperationWasPersistedBlock:))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn setLongLivedOperationWasPersistedBlock(
122 &self,
123 long_lived_operation_was_persisted_block: Option<&block2::DynBlock<dyn Fn()>>,
124 );
125 );
126}
127
128/// Methods declared on superclass `NSObject`.
129impl CKOperation {
130 extern_methods!(
131 #[unsafe(method(new))]
132 #[unsafe(method_family = new)]
133 pub unsafe fn new() -> Retained<Self>;
134 );
135}
136
137extern_class!(
138 /// An operation configuration is a set of properties that describes how your operation should behave. All properties have a default value. When determining what properties to apply to an operation, we consult the operation's configuration property, as well as the operation->group->defaultConfiguration property. We combine them following these rules:
139 ///
140 /// ```text
141 /// Group Default Configuration Value | Operation Configuration Value | Value Applied To Operation
142 /// -----------------------------------+-------------------------------+-----------------------------------------
143 /// default value | default value | default value
144 /// default value | explicit value | operation.configuration explicit value
145 /// explicit value | default value | operation.group.defaultConfiguration explicit value
146 /// explicit value | explicit value | operation.configuration explicit value
147 /// ```
148 ///
149 /// For example:
150 /// CKOperationGroup -> defaultConfiguration -> allowsCellularAccess explicitly set to NO
151 /// + CKOperation -> configuration -> allowsCellularAccess has default value of YES
152 /// = disallow cellular access
153 ///
154 /// CKOperationGroup -> defaultConfiguration -> allowsCellularAccess explicitly set to NO
155 /// + CKOperation -> configuration -> allowsCellularAccess explicitly set to YES
156 /// = allow cellular access
157 ///
158 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckoperationconfiguration?language=objc)
159 #[unsafe(super(NSObject))]
160 #[derive(Debug, PartialEq, Eq, Hash)]
161 pub struct CKOperationConfiguration;
162);
163
164extern_conformance!(
165 unsafe impl NSObjectProtocol for CKOperationConfiguration {}
166);
167
168impl CKOperationConfiguration {
169 extern_methods!(
170 #[cfg(feature = "CKContainer")]
171 /// If no container is set, [CKContainer defaultContainer] is used
172 #[unsafe(method(container))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn container(&self) -> Option<Retained<CKContainer>>;
175
176 #[cfg(feature = "CKContainer")]
177 /// Setter for [`container`][Self::container].
178 #[unsafe(method(setContainer:))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn setContainer(&self, container: Option<&CKContainer>);
181
182 /// CKOperations behave differently depending on how you set qualityOfService.
183 ///
184 ///
185 /// ```text
186 /// Quality of Service | timeoutIntervalForResource | Network Error Behavior | Discretionary Behavior
187 /// -------------------+----------------------------+------------------------+-----------------------
188 /// UserInteractive | -1 (no enforcement) | fail | nonDiscretionary
189 /// UserInitiated | -1 (no enforcement) | fail | nonDiscretionary
190 /// Default | 1 week | fail | discretionary when app backgrounded
191 /// Utility | 1 week | internally retried | discretionary when app backgrounded
192 /// Background | 1 week | internally retried | discretionary
193 /// ```
194 ///
195 /// timeoutIntervalForResource
196 /// - the timeout interval for any network resources retrieved by this operation
197 /// - this can be overridden via CKOperationConfiguration's timeoutIntervalForResource property
198 ///
199 /// Network Error Behavior
200 /// - when a network request in service of a CKOperation fails due to a networking error, the operation may fail with that error, or internally retry the network request. Only a subset of networking errors are retried, and limiting factors such as timeoutIntervalForResource are still applicable.
201 ///
202 /// Discretionary Behavior
203 /// - network requests in service of a CKOperation may be marked as discretionary
204 /// - discretionary network requests are scheduled at the description of the system for optimal performance
205 ///
206 /// CKOperations have a default qualityOfService of Default.
207 #[unsafe(method(qualityOfService))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn qualityOfService(&self) -> NSQualityOfService;
210
211 /// Setter for [`qualityOfService`][Self::qualityOfService].
212 #[unsafe(method(setQualityOfService:))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
215
216 /// Defaults to
217 /// `YES`
218 #[unsafe(method(allowsCellularAccess))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn allowsCellularAccess(&self) -> bool;
221
222 /// Setter for [`allowsCellularAccess`][Self::allowsCellularAccess].
223 #[unsafe(method(setAllowsCellularAccess:))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn setAllowsCellularAccess(&self, allows_cellular_access: bool);
226
227 /// Long lived operations will continue running even if your process exits. If your process remains alive for the lifetime of the long lived operation its behavior is the same as a regular operation.
228 ///
229 /// Long lived operations can be fetched and replayed from the container via the
230 /// `fetchAllLongLivedOperations:`and
231 /// `fetchLongLivedOperationsWithIDs:`APIs. Your code should only fetch and re-enqueue long lived operations on app launch.
232 ///
233 /// Long lived operations persist until their -[NSOperation completionBlock] returns or until the operation is cancelled.
234 /// Long lived operations may be garbage collected 24 hours after they finish running if no client has replayed them.
235 ///
236 /// The default value for longLived is NO. Changing the value of longLived on an already started operation or on an outstanding long lived operation fetched from CKContainer has no effect.
237 #[unsafe(method(isLongLived))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn isLongLived(&self) -> bool;
240
241 /// Setter for [`isLongLived`][Self::isLongLived].
242 #[unsafe(method(setLongLived:))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn setLongLived(&self, long_lived: bool);
245
246 /// If non-zero, overrides the timeout interval for any network requests issued by this operation.
247 /// The default value is 60.
248 ///
249 ///
250 /// See: NSURLSessionConfiguration.timeoutIntervalForRequest
251 #[unsafe(method(timeoutIntervalForRequest))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn timeoutIntervalForRequest(&self) -> NSTimeInterval;
254
255 /// Setter for [`timeoutIntervalForRequest`][Self::timeoutIntervalForRequest].
256 #[unsafe(method(setTimeoutIntervalForRequest:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn setTimeoutIntervalForRequest(
259 &self,
260 timeout_interval_for_request: NSTimeInterval,
261 );
262
263 /// If set, overrides the timeout interval for any network resources retrieved by this operation.
264 /// If not explicitly set, defaults to a value based on the operation's
265 /// `qualityOfService`
266 ///
267 /// See: NSURLSessionConfiguration.timeoutIntervalForResource
268 #[unsafe(method(timeoutIntervalForResource))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn timeoutIntervalForResource(&self) -> NSTimeInterval;
271
272 /// Setter for [`timeoutIntervalForResource`][Self::timeoutIntervalForResource].
273 #[unsafe(method(setTimeoutIntervalForResource:))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn setTimeoutIntervalForResource(
276 &self,
277 timeout_interval_for_resource: NSTimeInterval,
278 );
279 );
280}
281
282/// Methods declared on superclass `NSObject`.
283impl CKOperationConfiguration {
284 extern_methods!(
285 #[unsafe(method(init))]
286 #[unsafe(method_family = init)]
287 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
288
289 #[unsafe(method(new))]
290 #[unsafe(method_family = new)]
291 pub unsafe fn new() -> Retained<Self>;
292 );
293}
294
295/// CKOperationDeprecated.
296///
297/// These deprecated properties now read and write from the CKOperation's configuration
298impl CKOperation {
299 extern_methods!(
300 #[cfg(feature = "CKContainer")]
301 /// This property is not atomic.
302 ///
303 /// # Safety
304 ///
305 /// This might not be thread-safe.
306 #[deprecated = "Use CKOperationConfiguration"]
307 #[unsafe(method(container))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn container(&self) -> Option<Retained<CKContainer>>;
310
311 #[cfg(feature = "CKContainer")]
312 /// Setter for [`container`][Self::container].
313 ///
314 /// # Safety
315 ///
316 /// This might not be thread-safe.
317 #[deprecated = "Use CKOperationConfiguration"]
318 #[unsafe(method(setContainer:))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn setContainer(&self, container: Option<&CKContainer>);
321
322 /// This property is not atomic.
323 ///
324 /// # Safety
325 ///
326 /// This might not be thread-safe.
327 #[deprecated = "Use CKOperationConfiguration"]
328 #[unsafe(method(allowsCellularAccess))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn allowsCellularAccess(&self) -> bool;
331
332 /// Setter for [`allowsCellularAccess`][Self::allowsCellularAccess].
333 ///
334 /// # Safety
335 ///
336 /// This might not be thread-safe.
337 #[deprecated = "Use CKOperationConfiguration"]
338 #[unsafe(method(setAllowsCellularAccess:))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn setAllowsCellularAccess(&self, allows_cellular_access: bool);
341
342 /// This property is not atomic.
343 ///
344 /// # Safety
345 ///
346 /// This might not be thread-safe.
347 #[deprecated = "Use CKOperationConfiguration"]
348 #[unsafe(method(isLongLived))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn isLongLived(&self) -> bool;
351
352 /// Setter for [`isLongLived`][Self::isLongLived].
353 ///
354 /// # Safety
355 ///
356 /// This might not be thread-safe.
357 #[deprecated = "Use CKOperationConfiguration"]
358 #[unsafe(method(setLongLived:))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn setLongLived(&self, long_lived: bool);
361
362 /// This property is not atomic.
363 ///
364 /// # Safety
365 ///
366 /// This might not be thread-safe.
367 #[deprecated = "Use CKOperationConfiguration"]
368 #[unsafe(method(timeoutIntervalForRequest))]
369 #[unsafe(method_family = none)]
370 pub unsafe fn timeoutIntervalForRequest(&self) -> NSTimeInterval;
371
372 /// Setter for [`timeoutIntervalForRequest`][Self::timeoutIntervalForRequest].
373 ///
374 /// # Safety
375 ///
376 /// This might not be thread-safe.
377 #[deprecated = "Use CKOperationConfiguration"]
378 #[unsafe(method(setTimeoutIntervalForRequest:))]
379 #[unsafe(method_family = none)]
380 pub unsafe fn setTimeoutIntervalForRequest(
381 &self,
382 timeout_interval_for_request: NSTimeInterval,
383 );
384
385 /// This property is not atomic.
386 ///
387 /// # Safety
388 ///
389 /// This might not be thread-safe.
390 #[deprecated = "Use CKOperationConfiguration"]
391 #[unsafe(method(timeoutIntervalForResource))]
392 #[unsafe(method_family = none)]
393 pub unsafe fn timeoutIntervalForResource(&self) -> NSTimeInterval;
394
395 /// Setter for [`timeoutIntervalForResource`][Self::timeoutIntervalForResource].
396 ///
397 /// # Safety
398 ///
399 /// This might not be thread-safe.
400 #[deprecated = "Use CKOperationConfiguration"]
401 #[unsafe(method(setTimeoutIntervalForResource:))]
402 #[unsafe(method_family = none)]
403 pub unsafe fn setTimeoutIntervalForResource(
404 &self,
405 timeout_interval_for_resource: NSTimeInterval,
406 );
407 );
408}