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