objc2_cloud_kit/generated/CKModifyRecordsOperation.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/// Locally edited keys are sent to the server, updating the record if the server record has not been modified. This is the default and recommended save policy for regular use.
11/// This policy compares the record change tag with the server record, and may return
12/// `CKErrorServerRecordChanged`if the server record has been modified, for example by another device.
13/// Note: A
14/// `CKShare`record is always treated as
15/// `CKRecordSaveIfServerRecordUnchanged,`regardless of the
16/// `savePolicy`of the operation that modifies the share.
17///
18///
19///
20/// Locally edited keys are written to the server, updating the record even if the server record has been modified.
21/// Note: This policy should be used with care, as it can overwrite changes made by other devices.
22/// Any previously committed change to the server, for example by other devices, will always be overwritten by the locally changed value.
23/// Note: A
24/// `CKShare`record is always treated as
25/// `CKRecordSaveIfServerRecordUnchanged,`regardless of the
26/// `savePolicy`of the operation that modifies the share.
27/// For non-CKShare records, this policy does not compare the record change tag and therefore will not return
28/// `CKErrorServerRecordChanged`
29///
30///
31/// All local keys are written to the server, updating the record even if the server record has been modified.
32/// Note: This policy should be used with care. Any previously committed change to the server, for example by other devices, will be overwritten by the local value.
33/// Keys present only on the server remain unchanged.
34/// There are two common ways in which a server record will contain keys not present locally:
35/// 1 - Another client may have added a new key to the record since it was fetched.
36/// 2 - If
37/// `desiredKeys`was used with the fetch / query that returned this record, only a portion of the record's keys may have been downloaded.
38/// Note: A
39/// `CKShare`record is always treated as
40/// `CKRecordSaveIfServerRecordUnchanged,`regardless of the
41/// `savePolicy`of the operation that modifies the share.
42/// For non-CKShare records, this policy does not compare the record change tag and therefore will not return
43/// `CKErrorServerRecordChanged`
44///
45/// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordsavepolicy?language=objc)
46// NS_ENUM
47#[repr(transparent)]
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
49pub struct CKRecordSavePolicy(pub NSInteger);
50impl CKRecordSavePolicy {
51 #[doc(alias = "CKRecordSaveIfServerRecordUnchanged")]
52 pub const IfServerRecordUnchanged: Self = Self(0);
53 #[doc(alias = "CKRecordSaveChangedKeys")]
54 pub const ChangedKeys: Self = Self(1);
55 /// Does not compare record change tags
56 #[doc(alias = "CKRecordSaveAllKeys")]
57 pub const AllKeys: Self = Self(2);
58}
59
60unsafe impl Encode for CKRecordSavePolicy {
61 const ENCODING: Encoding = NSInteger::ENCODING;
62}
63
64unsafe impl RefEncode for CKRecordSavePolicy {
65 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
66}
67
68extern_class!(
69 /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckmodifyrecordsoperation?language=objc)
70 #[unsafe(super(CKDatabaseOperation, CKOperation, NSOperation, NSObject))]
71 #[derive(Debug, PartialEq, Eq, Hash)]
72 #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
73 pub struct CKModifyRecordsOperation;
74);
75
76#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
77extern_conformance!(
78 unsafe impl NSObjectProtocol for CKModifyRecordsOperation {}
79);
80
81#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
82impl CKModifyRecordsOperation {
83 extern_methods!(
84 #[unsafe(method(init))]
85 #[unsafe(method_family = init)]
86 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
87
88 #[cfg(all(feature = "CKRecord", feature = "CKRecordID"))]
89 #[unsafe(method(initWithRecordsToSave:recordIDsToDelete:))]
90 #[unsafe(method_family = init)]
91 pub unsafe fn initWithRecordsToSave_recordIDsToDelete(
92 this: Allocated<Self>,
93 records: Option<&NSArray<CKRecord>>,
94 record_i_ds: Option<&NSArray<CKRecordID>>,
95 ) -> Retained<Self>;
96
97 #[cfg(feature = "CKRecord")]
98 /// This property is not atomic.
99 ///
100 /// # Safety
101 ///
102 /// This might not be thread-safe.
103 #[unsafe(method(recordsToSave))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn recordsToSave(&self) -> Option<Retained<NSArray<CKRecord>>>;
106
107 #[cfg(feature = "CKRecord")]
108 /// Setter for [`recordsToSave`][Self::recordsToSave].
109 ///
110 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
111 ///
112 /// # Safety
113 ///
114 /// This might not be thread-safe.
115 #[unsafe(method(setRecordsToSave:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn setRecordsToSave(&self, records_to_save: Option<&NSArray<CKRecord>>);
118
119 #[cfg(feature = "CKRecordID")]
120 /// This property is not atomic.
121 ///
122 /// # Safety
123 ///
124 /// This might not be thread-safe.
125 #[unsafe(method(recordIDsToDelete))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn recordIDsToDelete(&self) -> Option<Retained<NSArray<CKRecordID>>>;
128
129 #[cfg(feature = "CKRecordID")]
130 /// Setter for [`recordIDsToDelete`][Self::recordIDsToDelete].
131 ///
132 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
133 ///
134 /// # Safety
135 ///
136 /// This might not be thread-safe.
137 #[unsafe(method(setRecordIDsToDelete:))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn setRecordIDsToDelete(
140 &self,
141 record_i_ds_to_delete: Option<&NSArray<CKRecordID>>,
142 );
143
144 /// Determines what data is sent to the server and whether the save should succeed even if the record on the server has changed.
145 ///
146 ///
147 /// : The default value is
148 /// `CKRecordSaveIfServerRecordUnchanged,`which is the recommended value for regular use.
149 /// A
150 /// `CKShare`record is always treated as
151 /// `CKRecordSaveIfServerRecordUnchanged,`regardless of the
152 /// `savePolicy`specified.
153 ///
154 /// This property is not atomic.
155 ///
156 /// # Safety
157 ///
158 /// This might not be thread-safe.
159 #[unsafe(method(savePolicy))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn savePolicy(&self) -> CKRecordSavePolicy;
162
163 /// Setter for [`savePolicy`][Self::savePolicy].
164 ///
165 /// # Safety
166 ///
167 /// This might not be thread-safe.
168 #[unsafe(method(setSavePolicy:))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn setSavePolicy(&self, save_policy: CKRecordSavePolicy);
171
172 /// This property is kept by the server to identify the last known request from this client.
173 /// Multiple requests from the client with the same change token will be ignored by the server.
174 ///
175 /// This property is not atomic.
176 ///
177 /// # Safety
178 ///
179 /// This might not be thread-safe.
180 #[unsafe(method(clientChangeTokenData))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn clientChangeTokenData(&self) -> Option<Retained<NSData>>;
183
184 /// Setter for [`clientChangeTokenData`][Self::clientChangeTokenData].
185 ///
186 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
187 ///
188 /// # Safety
189 ///
190 /// This might not be thread-safe.
191 #[unsafe(method(setClientChangeTokenData:))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn setClientChangeTokenData(&self, client_change_token_data: Option<&NSData>);
194
195 /// Determines whether the batch should fail atomically or not.
196 ///
197 ///
198 /// YES by default.
199 /// Server-side write atomicity is only enforced on zones that have
200 /// `CKRecordZoneCapabilityAtomic.`If
201 /// `isAtomic`is YES, client-side checks are enforced regardless of the zone's capabilities. (For example, if a record is malformed, and cannot be sent to the server, the client will forcibly fail all other records-to-be-modified in that zone)
202 ///
203 /// This property is not atomic.
204 ///
205 /// # Safety
206 ///
207 /// This might not be thread-safe.
208 #[unsafe(method(atomic))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn atomic(&self) -> bool;
211
212 /// Setter for [`atomic`][Self::atomic].
213 ///
214 /// # Safety
215 ///
216 /// This might not be thread-safe.
217 #[unsafe(method(setAtomic:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn setAtomic(&self, atomic: bool);
220
221 #[cfg(all(feature = "CKRecord", feature = "block2"))]
222 /// Indicates the progress for each record.
223 ///
224 ///
225 /// This method is called at least once with a progress of 1.0 for every record. Intermediate progress is only reported for records that contain assets.
226 /// It is possible for progress to regress when a retry is automatically triggered.
227 /// Each
228 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
229 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
230 /// should not be concurrently used outside of blocks assigned to this operation.
231 ///
232 /// This property is not atomic.
233 ///
234 /// # Safety
235 ///
236 /// - The returned block's argument 1 must be a valid pointer.
237 /// - This might not be thread-safe.
238 #[unsafe(method(perRecordProgressBlock))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn perRecordProgressBlock(
241 &self,
242 ) -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecord>, c_double)>;
243
244 #[cfg(all(feature = "CKRecord", feature = "block2"))]
245 /// Setter for [`perRecordProgressBlock`][Self::perRecordProgressBlock].
246 ///
247 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
248 ///
249 /// # Safety
250 ///
251 /// This might not be thread-safe.
252 #[unsafe(method(setPerRecordProgressBlock:))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn setPerRecordProgressBlock(
255 &self,
256 per_record_progress_block: Option<
257 &block2::DynBlock<dyn Fn(NonNull<CKRecord>, c_double)>,
258 >,
259 );
260
261 #[cfg(all(feature = "CKRecord", feature = "block2"))]
262 /// Called on success or failure for each record.
263 ///
264 ///
265 /// Will not be invoked if
266 /// `perRecordSaveBlock`is set.
267 /// Each
268 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
269 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
270 /// should not be concurrently used outside of blocks assigned to this operation.
271 ///
272 /// This property is not atomic.
273 ///
274 /// # Safety
275 ///
276 /// - The returned block's argument 1 must be a valid pointer.
277 /// - The returned block's argument 2 must be a valid pointer or null.
278 /// - This might not be thread-safe.
279 #[deprecated]
280 #[unsafe(method(perRecordCompletionBlock))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn perRecordCompletionBlock(
283 &self,
284 ) -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecord>, *mut NSError)>;
285
286 #[cfg(all(feature = "CKRecord", feature = "block2"))]
287 /// Setter for [`perRecordCompletionBlock`][Self::perRecordCompletionBlock].
288 ///
289 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
290 ///
291 /// # Safety
292 ///
293 /// This might not be thread-safe.
294 #[deprecated]
295 #[unsafe(method(setPerRecordCompletionBlock:))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn setPerRecordCompletionBlock(
298 &self,
299 per_record_completion_block: Option<
300 &block2::DynBlock<dyn Fn(NonNull<CKRecord>, *mut NSError)>,
301 >,
302 );
303
304 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
305 /// Called on success or failure of a record save
306 ///
307 ///
308 /// Following a successful record save, this callback will be invoked with a nonnull
309 /// `record,`and a nil
310 /// `error.`Following a save failure due to a per-item error (
311 /// `CKErrorServerRecordChanged,`for example), this callback will be invoked with a nil
312 /// `record,`and a nonnull
313 /// `error`Each
314 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
315 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
316 /// should not be concurrently used outside of blocks assigned to this operation.
317 ///
318 /// This property is not atomic.
319 ///
320 /// # Safety
321 ///
322 /// - The returned block's argument 1 must be a valid pointer.
323 /// - The returned block's argument 2 must be a valid pointer or null.
324 /// - The returned block's argument 3 must be a valid pointer or null.
325 /// - This might not be thread-safe.
326 #[unsafe(method(perRecordSaveBlock))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn perRecordSaveBlock(
329 &self,
330 ) -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>;
331
332 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
333 /// Setter for [`perRecordSaveBlock`][Self::perRecordSaveBlock].
334 ///
335 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
336 ///
337 /// # Safety
338 ///
339 /// This might not be thread-safe.
340 #[unsafe(method(setPerRecordSaveBlock:))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn setPerRecordSaveBlock(
343 &self,
344 per_record_save_block: Option<
345 &block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>,
346 >,
347 );
348
349 #[cfg(all(feature = "CKRecordID", feature = "block2"))]
350 /// Called on success or failure of a record deletion
351 ///
352 /// Each
353 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
354 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
355 /// should not be concurrently used outside of blocks assigned to this operation.
356 ///
357 /// This property is not atomic.
358 ///
359 /// # Safety
360 ///
361 /// - The returned block's argument 1 must be a valid pointer.
362 /// - The returned block's argument 2 must be a valid pointer or null.
363 /// - This might not be thread-safe.
364 #[unsafe(method(perRecordDeleteBlock))]
365 #[unsafe(method_family = none)]
366 pub unsafe fn perRecordDeleteBlock(
367 &self,
368 ) -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut NSError)>;
369
370 #[cfg(all(feature = "CKRecordID", feature = "block2"))]
371 /// Setter for [`perRecordDeleteBlock`][Self::perRecordDeleteBlock].
372 ///
373 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
374 ///
375 /// # Safety
376 ///
377 /// This might not be thread-safe.
378 #[unsafe(method(setPerRecordDeleteBlock:))]
379 #[unsafe(method_family = none)]
380 pub unsafe fn setPerRecordDeleteBlock(
381 &self,
382 per_record_delete_block: Option<
383 &block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut NSError)>,
384 >,
385 );
386
387 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
388 /// This block is called when the operation completes.
389 ///
390 ///
391 /// The
392 ///
393 /// ```text
394 /// -[NSOperation completionBlock]
395 /// ```
396 ///
397 /// will also be called if both are set.
398 /// If the error is
399 /// `CKErrorPartialFailure,`the error's userInfo dictionary contains a dictionary of recordIDs to errors keyed off of
400 /// `CKPartialErrorsByItemIDKey.``savedRecords,``deletedRecordIDs`and any
401 /// `CKPartialErrorsByItemIDKey`errors are repeats of the data sent back in previous
402 /// `perRecordSaveBlock`and
403 /// `perRecordDeleteBlock`invocations
404 /// This call happens as soon as the server has seen all record changes, and may be invoked while the server is processing the side effects of those changes.
405 /// Each
406 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
407 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
408 /// should not be concurrently used outside of blocks assigned to this operation.
409 ///
410 /// This property is not atomic.
411 ///
412 /// # Safety
413 ///
414 /// - The returned block's argument 1 must be a valid pointer or null.
415 /// - The returned block's argument 2 must be a valid pointer or null.
416 /// - The returned block's argument 3 must be a valid pointer or null.
417 /// - This might not be thread-safe.
418 #[unsafe(method(modifyRecordsCompletionBlock))]
419 #[unsafe(method_family = none)]
420 pub unsafe fn modifyRecordsCompletionBlock(
421 &self,
422 ) -> *mut block2::DynBlock<
423 dyn Fn(*mut NSArray<CKRecord>, *mut NSArray<CKRecordID>, *mut NSError),
424 >;
425
426 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
427 /// Setter for [`modifyRecordsCompletionBlock`][Self::modifyRecordsCompletionBlock].
428 ///
429 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
430 ///
431 /// # Safety
432 ///
433 /// This might not be thread-safe.
434 #[unsafe(method(setModifyRecordsCompletionBlock:))]
435 #[unsafe(method_family = none)]
436 pub unsafe fn setModifyRecordsCompletionBlock(
437 &self,
438 modify_records_completion_block: Option<
439 &block2::DynBlock<
440 dyn Fn(*mut NSArray<CKRecord>, *mut NSArray<CKRecordID>, *mut NSError),
441 >,
442 >,
443 );
444 );
445}
446
447/// Methods declared on superclass `NSObject`.
448#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
449impl CKModifyRecordsOperation {
450 extern_methods!(
451 #[unsafe(method(new))]
452 #[unsafe(method_family = new)]
453 pub unsafe fn new() -> Retained<Self>;
454 );
455}