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"))]
77unsafe impl NSObjectProtocol for CKModifyRecordsOperation {}
78
79#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
80impl CKModifyRecordsOperation {
81 extern_methods!(
82 #[unsafe(method(init))]
83 #[unsafe(method_family = init)]
84 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
85
86 #[cfg(all(feature = "CKRecord", feature = "CKRecordID"))]
87 #[unsafe(method(initWithRecordsToSave:recordIDsToDelete:))]
88 #[unsafe(method_family = init)]
89 pub unsafe fn initWithRecordsToSave_recordIDsToDelete(
90 this: Allocated<Self>,
91 records: Option<&NSArray<CKRecord>>,
92 record_i_ds: Option<&NSArray<CKRecordID>>,
93 ) -> Retained<Self>;
94
95 #[cfg(feature = "CKRecord")]
96 #[unsafe(method(recordsToSave))]
97 #[unsafe(method_family = none)]
98 pub unsafe fn recordsToSave(&self) -> Option<Retained<NSArray<CKRecord>>>;
99
100 #[cfg(feature = "CKRecord")]
101 /// Setter for [`recordsToSave`][Self::recordsToSave].
102 #[unsafe(method(setRecordsToSave:))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn setRecordsToSave(&self, records_to_save: Option<&NSArray<CKRecord>>);
105
106 #[cfg(feature = "CKRecordID")]
107 #[unsafe(method(recordIDsToDelete))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn recordIDsToDelete(&self) -> Option<Retained<NSArray<CKRecordID>>>;
110
111 #[cfg(feature = "CKRecordID")]
112 /// Setter for [`recordIDsToDelete`][Self::recordIDsToDelete].
113 #[unsafe(method(setRecordIDsToDelete:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn setRecordIDsToDelete(
116 &self,
117 record_i_ds_to_delete: Option<&NSArray<CKRecordID>>,
118 );
119
120 /// Determines what data is sent to the server and whether the save should succeed even if the record on the server has changed.
121 ///
122 ///
123 /// : The default value is
124 /// `CKRecordSaveIfServerRecordUnchanged,`which is the recommended value for regular use.
125 /// A
126 /// `CKShare`record is always treated as
127 /// `CKRecordSaveIfServerRecordUnchanged,`regardless of the
128 /// `savePolicy`specified.
129 #[unsafe(method(savePolicy))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn savePolicy(&self) -> CKRecordSavePolicy;
132
133 /// Setter for [`savePolicy`][Self::savePolicy].
134 #[unsafe(method(setSavePolicy:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn setSavePolicy(&self, save_policy: CKRecordSavePolicy);
137
138 /// This property is kept by the server to identify the last known request from this client.
139 /// Multiple requests from the client with the same change token will be ignored by the server.
140 #[unsafe(method(clientChangeTokenData))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn clientChangeTokenData(&self) -> Option<Retained<NSData>>;
143
144 /// Setter for [`clientChangeTokenData`][Self::clientChangeTokenData].
145 #[unsafe(method(setClientChangeTokenData:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn setClientChangeTokenData(&self, client_change_token_data: Option<&NSData>);
148
149 /// Determines whether the batch should fail atomically or not.
150 ///
151 ///
152 /// YES by default.
153 /// Server-side write atomicity is only enforced on zones that have
154 /// `CKRecordZoneCapabilityAtomic.`If
155 /// `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)
156 #[unsafe(method(atomic))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn atomic(&self) -> bool;
159
160 /// Setter for [`atomic`][Self::atomic].
161 #[unsafe(method(setAtomic:))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn setAtomic(&self, atomic: bool);
164
165 #[cfg(all(feature = "CKRecord", feature = "block2"))]
166 /// Indicates the progress for each record.
167 ///
168 ///
169 /// 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.
170 /// It is possible for progress to regress when a retry is automatically triggered.
171 /// Each
172 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
173 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
174 /// should not be concurrently used outside of blocks assigned to this operation.
175 #[unsafe(method(perRecordProgressBlock))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn perRecordProgressBlock(
178 &self,
179 ) -> *mut block2::Block<dyn Fn(NonNull<CKRecord>, c_double)>;
180
181 #[cfg(all(feature = "CKRecord", feature = "block2"))]
182 /// Setter for [`perRecordProgressBlock`][Self::perRecordProgressBlock].
183 #[unsafe(method(setPerRecordProgressBlock:))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn setPerRecordProgressBlock(
186 &self,
187 per_record_progress_block: Option<&block2::Block<dyn Fn(NonNull<CKRecord>, c_double)>>,
188 );
189
190 #[cfg(all(feature = "CKRecord", feature = "block2"))]
191 /// Called on success or failure for each record.
192 ///
193 ///
194 /// Will not be invoked if
195 /// `perRecordSaveBlock`is set.
196 /// Each
197 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
198 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
199 /// should not be concurrently used outside of blocks assigned to this operation.
200 #[deprecated]
201 #[unsafe(method(perRecordCompletionBlock))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn perRecordCompletionBlock(
204 &self,
205 ) -> *mut block2::Block<dyn Fn(NonNull<CKRecord>, *mut NSError)>;
206
207 #[cfg(all(feature = "CKRecord", feature = "block2"))]
208 /// Setter for [`perRecordCompletionBlock`][Self::perRecordCompletionBlock].
209 #[deprecated]
210 #[unsafe(method(setPerRecordCompletionBlock:))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn setPerRecordCompletionBlock(
213 &self,
214 per_record_completion_block: Option<
215 &block2::Block<dyn Fn(NonNull<CKRecord>, *mut NSError)>,
216 >,
217 );
218
219 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
220 /// Called on success or failure of a record save
221 ///
222 ///
223 /// Following a successful record save, this callback will be invoked with a nonnull
224 /// `record,`and a nil
225 /// `error.`Following a save failure due to a per-item error (
226 /// `CKErrorServerRecordChanged,`for example), this callback will be invoked with a nil
227 /// `record,`and a nonnull
228 /// `error`Each
229 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
230 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
231 /// should not be concurrently used outside of blocks assigned to this operation.
232 #[unsafe(method(perRecordSaveBlock))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn perRecordSaveBlock(
235 &self,
236 ) -> *mut block2::Block<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>;
237
238 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
239 /// Setter for [`perRecordSaveBlock`][Self::perRecordSaveBlock].
240 #[unsafe(method(setPerRecordSaveBlock:))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn setPerRecordSaveBlock(
243 &self,
244 per_record_save_block: Option<
245 &block2::Block<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>,
246 >,
247 );
248
249 #[cfg(all(feature = "CKRecordID", feature = "block2"))]
250 /// Called on success or failure of a record deletion
251 ///
252 /// Each
253 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
254 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
255 /// should not be concurrently used outside of blocks assigned to this operation.
256 #[unsafe(method(perRecordDeleteBlock))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn perRecordDeleteBlock(
259 &self,
260 ) -> *mut block2::Block<dyn Fn(NonNull<CKRecordID>, *mut NSError)>;
261
262 #[cfg(all(feature = "CKRecordID", feature = "block2"))]
263 /// Setter for [`perRecordDeleteBlock`][Self::perRecordDeleteBlock].
264 #[unsafe(method(setPerRecordDeleteBlock:))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn setPerRecordDeleteBlock(
267 &self,
268 per_record_delete_block: Option<
269 &block2::Block<dyn Fn(NonNull<CKRecordID>, *mut NSError)>,
270 >,
271 );
272
273 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
274 /// This block is called when the operation completes.
275 ///
276 ///
277 /// The
278 ///
279 /// ```text
280 /// -[NSOperation completionBlock]
281 /// ```
282 ///
283 /// will also be called if both are set.
284 /// If the error is
285 /// `CKErrorPartialFailure,`the error's userInfo dictionary contains a dictionary of recordIDs to errors keyed off of
286 /// `CKPartialErrorsByItemIDKey.``savedRecords,``deletedRecordIDs`and any
287 /// `CKPartialErrorsByItemIDKey`errors are repeats of the data sent back in previous
288 /// `perRecordSaveBlock`and
289 /// `perRecordDeleteBlock`invocations
290 /// 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.
291 /// Each
292 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
293 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
294 /// should not be concurrently used outside of blocks assigned to this operation.
295 #[unsafe(method(modifyRecordsCompletionBlock))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn modifyRecordsCompletionBlock(
298 &self,
299 ) -> *mut block2::Block<
300 dyn Fn(*mut NSArray<CKRecord>, *mut NSArray<CKRecordID>, *mut NSError),
301 >;
302
303 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
304 /// Setter for [`modifyRecordsCompletionBlock`][Self::modifyRecordsCompletionBlock].
305 #[unsafe(method(setModifyRecordsCompletionBlock:))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn setModifyRecordsCompletionBlock(
308 &self,
309 modify_records_completion_block: Option<
310 &block2::Block<
311 dyn Fn(*mut NSArray<CKRecord>, *mut NSArray<CKRecordID>, *mut NSError),
312 >,
313 >,
314 );
315 );
316}
317
318/// Methods declared on superclass `NSObject`.
319#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
320impl CKModifyRecordsOperation {
321 extern_methods!(
322 #[unsafe(method(new))]
323 #[unsafe(method_family = new)]
324 pub unsafe fn new() -> Retained<Self>;
325 );
326}