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        #[unsafe(method(configuration))]
35        #[unsafe(method_family = none)]
36        pub unsafe fn configuration(&self) -> Retained<CKOperationConfiguration>;
37
38        /// Setter for [`configuration`][Self::configuration].
39        #[unsafe(method(setConfiguration:))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn setConfiguration(&self, configuration: Option<&CKOperationConfiguration>);
42
43        #[cfg(feature = "CKOperationGroup")]
44        /// The group this operation is associated with
45        #[unsafe(method(group))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn group(&self) -> Option<Retained<CKOperationGroup>>;
48
49        #[cfg(feature = "CKOperationGroup")]
50        /// Setter for [`group`][Self::group].
51        #[unsafe(method(setGroup:))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn setGroup(&self, group: Option<&CKOperationGroup>);
54
55        /// This is an identifier unique to this CKOperation.
56        ///
57        ///
58        /// 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.
59        #[unsafe(method(operationID))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn operationID(&self) -> Retained<CKOperationID>;
62
63        #[cfg(feature = "block2")]
64        /// This callback is called after a long lived operation has begun running and is persisted.
65        ///
66        ///
67        /// Once this callback is called the operation will continue running even if the current process exits.
68        /// Each
69        /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
70        /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
71        /// should not be concurrently used outside of blocks assigned to this operation.
72        #[unsafe(method(longLivedOperationWasPersistedBlock))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn longLivedOperationWasPersistedBlock(&self)
75            -> *mut block2::DynBlock<dyn Fn()>;
76
77        #[cfg(feature = "block2")]
78        /// Setter for [`longLivedOperationWasPersistedBlock`][Self::longLivedOperationWasPersistedBlock].
79        #[unsafe(method(setLongLivedOperationWasPersistedBlock:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn setLongLivedOperationWasPersistedBlock(
82            &self,
83            long_lived_operation_was_persisted_block: Option<&block2::DynBlock<dyn Fn()>>,
84        );
85    );
86}
87
88/// Methods declared on superclass `NSObject`.
89impl CKOperation {
90    extern_methods!(
91        #[unsafe(method(new))]
92        #[unsafe(method_family = new)]
93        pub unsafe fn new() -> Retained<Self>;
94    );
95}
96
97extern_class!(
98    /// 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:
99    ///
100    /// ```text
101    ///    Group Default Configuration Value | Operation Configuration Value |        Value Applied To Operation
102    ///   -----------------------------------+-------------------------------+-----------------------------------------
103    ///              default value           |         default value         |                  default value
104    ///              default value           |         explicit value        |       operation.configuration explicit value
105    ///              explicit value          |         default value         | operation.group.defaultConfiguration explicit value
106    ///              explicit value          |         explicit value        |       operation.configuration explicit value
107    /// ```
108    ///
109    /// For example:
110    /// CKOperationGroup -> defaultConfiguration -> allowsCellularAccess explicitly set to NO
111    /// + CKOperation -> configuration -> allowsCellularAccess has default value of YES
112    /// = disallow cellular access
113    ///
114    /// CKOperationGroup -> defaultConfiguration -> allowsCellularAccess explicitly set to NO
115    /// + CKOperation -> configuration -> allowsCellularAccess explicitly set to YES
116    /// = allow cellular access
117    ///
118    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckoperationconfiguration?language=objc)
119    #[unsafe(super(NSObject))]
120    #[derive(Debug, PartialEq, Eq, Hash)]
121    pub struct CKOperationConfiguration;
122);
123
124extern_conformance!(
125    unsafe impl NSObjectProtocol for CKOperationConfiguration {}
126);
127
128impl CKOperationConfiguration {
129    extern_methods!(
130        #[cfg(feature = "CKContainer")]
131        /// If no container is set, [CKContainer defaultContainer] is used
132        #[unsafe(method(container))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn container(&self) -> Option<Retained<CKContainer>>;
135
136        #[cfg(feature = "CKContainer")]
137        /// Setter for [`container`][Self::container].
138        #[unsafe(method(setContainer:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn setContainer(&self, container: Option<&CKContainer>);
141
142        /// CKOperations behave differently depending on how you set qualityOfService.
143        ///
144        ///
145        /// ```text
146        ///   Quality of Service | timeoutIntervalForResource | Network Error Behavior | Discretionary Behavior
147        ///   -------------------+----------------------------+------------------------+-----------------------
148        ///   UserInteractive    | -1 (no enforcement)        | fail                   | nonDiscretionary
149        ///   UserInitiated      | -1 (no enforcement)        | fail                   | nonDiscretionary
150        ///   Default            | 1 week                     | fail                   | discretionary when app backgrounded
151        ///   Utility            | 1 week                     | internally retried     | discretionary when app backgrounded
152        ///   Background         | 1 week                     | internally retried     | discretionary
153        /// ```
154        ///
155        /// timeoutIntervalForResource
156        /// - the timeout interval for any network resources retrieved by this operation
157        /// - this can be overridden via CKOperationConfiguration's timeoutIntervalForResource property
158        ///
159        /// Network Error Behavior
160        /// - 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.
161        ///
162        /// Discretionary Behavior
163        /// - network requests in service of a CKOperation may be marked as discretionary
164        /// - discretionary network requests are scheduled at the description of the system for optimal performance
165        ///
166        /// CKOperations have a default qualityOfService of Default.
167        #[unsafe(method(qualityOfService))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn qualityOfService(&self) -> NSQualityOfService;
170
171        /// Setter for [`qualityOfService`][Self::qualityOfService].
172        #[unsafe(method(setQualityOfService:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
175
176        /// Defaults to
177        /// `YES`
178        #[unsafe(method(allowsCellularAccess))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn allowsCellularAccess(&self) -> bool;
181
182        /// Setter for [`allowsCellularAccess`][Self::allowsCellularAccess].
183        #[unsafe(method(setAllowsCellularAccess:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setAllowsCellularAccess(&self, allows_cellular_access: bool);
186
187        /// 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.
188        ///
189        /// Long lived operations can be fetched and replayed from the container via the
190        /// `fetchAllLongLivedOperations:`and
191        /// `fetchLongLivedOperationsWithIDs:`APIs. Your code should only fetch and re-enqueue long lived operations on app launch.
192        ///
193        /// Long lived operations persist until their -[NSOperation completionBlock] returns or until the operation is cancelled.
194        /// Long lived operations may be garbage collected 24 hours after they finish running if no client has replayed them.
195        ///
196        /// 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.
197        #[unsafe(method(isLongLived))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn isLongLived(&self) -> bool;
200
201        /// Setter for [`isLongLived`][Self::isLongLived].
202        #[unsafe(method(setLongLived:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setLongLived(&self, long_lived: bool);
205
206        /// If non-zero, overrides the timeout interval for any network requests issued by this operation.
207        /// The default value is 60.
208        ///
209        ///
210        /// See: NSURLSessionConfiguration.timeoutIntervalForRequest
211        #[unsafe(method(timeoutIntervalForRequest))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn timeoutIntervalForRequest(&self) -> NSTimeInterval;
214
215        /// Setter for [`timeoutIntervalForRequest`][Self::timeoutIntervalForRequest].
216        #[unsafe(method(setTimeoutIntervalForRequest:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setTimeoutIntervalForRequest(
219            &self,
220            timeout_interval_for_request: NSTimeInterval,
221        );
222
223        /// If set, overrides the timeout interval for any network resources retrieved by this operation.
224        /// If not explicitly set, defaults to a value based on the operation's
225        /// `qualityOfService`
226        ///
227        /// See: NSURLSessionConfiguration.timeoutIntervalForResource
228        #[unsafe(method(timeoutIntervalForResource))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn timeoutIntervalForResource(&self) -> NSTimeInterval;
231
232        /// Setter for [`timeoutIntervalForResource`][Self::timeoutIntervalForResource].
233        #[unsafe(method(setTimeoutIntervalForResource:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setTimeoutIntervalForResource(
236            &self,
237            timeout_interval_for_resource: NSTimeInterval,
238        );
239    );
240}
241
242/// Methods declared on superclass `NSObject`.
243impl CKOperationConfiguration {
244    extern_methods!(
245        #[unsafe(method(init))]
246        #[unsafe(method_family = init)]
247        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
248
249        #[unsafe(method(new))]
250        #[unsafe(method_family = new)]
251        pub unsafe fn new() -> Retained<Self>;
252    );
253}
254
255/// CKOperationDeprecated.
256/// These deprecated properties now read and write from the CKOperation's configuration
257impl CKOperation {
258    extern_methods!(
259        #[cfg(feature = "CKContainer")]
260        #[deprecated = "Use CKOperationConfiguration"]
261        #[unsafe(method(container))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn container(&self) -> Option<Retained<CKContainer>>;
264
265        #[cfg(feature = "CKContainer")]
266        /// Setter for [`container`][Self::container].
267        #[deprecated = "Use CKOperationConfiguration"]
268        #[unsafe(method(setContainer:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn setContainer(&self, container: Option<&CKContainer>);
271
272        #[deprecated = "Use CKOperationConfiguration"]
273        #[unsafe(method(allowsCellularAccess))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn allowsCellularAccess(&self) -> bool;
276
277        /// Setter for [`allowsCellularAccess`][Self::allowsCellularAccess].
278        #[deprecated = "Use CKOperationConfiguration"]
279        #[unsafe(method(setAllowsCellularAccess:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn setAllowsCellularAccess(&self, allows_cellular_access: bool);
282
283        #[deprecated = "Use CKOperationConfiguration"]
284        #[unsafe(method(isLongLived))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn isLongLived(&self) -> bool;
287
288        /// Setter for [`isLongLived`][Self::isLongLived].
289        #[deprecated = "Use CKOperationConfiguration"]
290        #[unsafe(method(setLongLived:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn setLongLived(&self, long_lived: bool);
293
294        #[deprecated = "Use CKOperationConfiguration"]
295        #[unsafe(method(timeoutIntervalForRequest))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn timeoutIntervalForRequest(&self) -> NSTimeInterval;
298
299        /// Setter for [`timeoutIntervalForRequest`][Self::timeoutIntervalForRequest].
300        #[deprecated = "Use CKOperationConfiguration"]
301        #[unsafe(method(setTimeoutIntervalForRequest:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn setTimeoutIntervalForRequest(
304            &self,
305            timeout_interval_for_request: NSTimeInterval,
306        );
307
308        #[deprecated = "Use CKOperationConfiguration"]
309        #[unsafe(method(timeoutIntervalForResource))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn timeoutIntervalForResource(&self) -> NSTimeInterval;
312
313        /// Setter for [`timeoutIntervalForResource`][Self::timeoutIntervalForResource].
314        #[deprecated = "Use CKOperationConfiguration"]
315        #[unsafe(method(setTimeoutIntervalForResource:))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn setTimeoutIntervalForResource(
318            &self,
319            timeout_interval_for_resource: NSTimeInterval,
320        );
321    );
322}