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