objc2_cloud_kit/generated/
CKSyncEngineEvent.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// An event that occurs during the operation of a `CKSyncEngine`.
10/// See ``CKSyncEngineEvent`` for more details.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncengineeventtype?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct CKSyncEngineEventType(pub NSInteger);
17impl CKSyncEngineEventType {
18    /// The sync engine state was updated. You should persist it locally.
19    #[doc(alias = "CKSyncEngineEventTypeStateUpdate")]
20    pub const StateUpdate: Self = Self(0);
21    /// The user signed in or out of their account.
22    #[doc(alias = "CKSyncEngineEventTypeAccountChange")]
23    pub const AccountChange: Self = Self(1);
24    /// The sync engine fetched new database changes from the server.
25    #[doc(alias = "CKSyncEngineEventTypeFetchedDatabaseChanges")]
26    pub const FetchedDatabaseChanges: Self = Self(2);
27    /// The sync engine fetched new record zone changes from the server.
28    #[doc(alias = "CKSyncEngineEventTypeFetchedRecordZoneChanges")]
29    pub const FetchedRecordZoneChanges: Self = Self(3);
30    /// The sync engine sent a batch of database changes to the server.
31    #[doc(alias = "CKSyncEngineEventTypeSentDatabaseChanges")]
32    pub const SentDatabaseChanges: Self = Self(4);
33    /// The sync engine sent a batch of record zone changes to the server.
34    #[doc(alias = "CKSyncEngineEventTypeSentRecordZoneChanges")]
35    pub const SentRecordZoneChanges: Self = Self(5);
36    /// The sync engine is about to fetch changes from the server.
37    #[doc(alias = "CKSyncEngineEventTypeWillFetchChanges")]
38    pub const WillFetchChanges: Self = Self(6);
39    /// The sync engine is about to fetch record zone changes from the server for a specific zone.
40    #[doc(alias = "CKSyncEngineEventTypeWillFetchRecordZoneChanges")]
41    pub const WillFetchRecordZoneChanges: Self = Self(7);
42    /// The sync engine finished fetching record zone changes from the server for a specific zone.
43    #[doc(alias = "CKSyncEngineEventTypeDidFetchRecordZoneChanges")]
44    pub const DidFetchRecordZoneChanges: Self = Self(8);
45    /// The sync engine finished fetching changes from the server.
46    #[doc(alias = "CKSyncEngineEventTypeDidFetchChanges")]
47    pub const DidFetchChanges: Self = Self(9);
48    /// The sync engine is about to send changes to the server.
49    #[doc(alias = "CKSyncEngineEventTypeWillSendChanges")]
50    pub const WillSendChanges: Self = Self(10);
51    /// The sync engine finished sending changes to the server.
52    #[doc(alias = "CKSyncEngineEventTypeDidSendChanges")]
53    pub const DidSendChanges: Self = Self(11);
54}
55
56unsafe impl Encode for CKSyncEngineEventType {
57    const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for CKSyncEngineEventType {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64extern_class!(
65    /// An event that occurs during the operation of a `CKSyncEngine`.
66    ///
67    /// While syncing, `CKSyncEngine` posts several different types of events.
68    /// Each event has an associated struct value with details describing the nature of the event.
69    ///
70    /// At a high level, the sync engine events can be grouped into a few different categories:
71    ///
72    /// ## Local state changes
73    ///
74    /// - ``CKSyncEngineStateUpdateEvent``
75    /// - ``CKSyncEngineAccountChangeEvent``
76    ///
77    /// ## Fetched changes
78    ///
79    /// - ``CKSyncEngineFetchedDatabaseChangesEvent``
80    /// - ``CKSyncEngineFetchedRecordZoneChangesEvent``
81    ///
82    /// ## Sent changes
83    ///
84    /// - ``CKSyncEngineSentDatabaseChangesEvent``
85    /// - ``CKSyncEngineSentRecordZoneChangesEvent``
86    ///
87    /// ## Fetch changes lifecycle
88    ///
89    /// - ``CKSyncEngineWillFetchChangesEvent``
90    /// - ``CKSyncEngineWillFetchRecordZoneChangesEvent``
91    /// - ``CKSyncEngineDidFetchRecordZoneChangesEvent``
92    /// - ``CKSyncEngineDidFetchChangesEvent``
93    ///
94    /// ## Send changes lifecycle
95    ///
96    /// - ``CKSyncEngineWillSendChangesEvent``
97    /// - ``CKSyncEngineDidSendChangesEvent``
98    ///
99    /// See the documentation for each event struct for more details about when and why an event might be posted.
100    ///
101    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncengineevent?language=objc)
102    #[unsafe(super(NSObject))]
103    #[derive(Debug, PartialEq, Eq, Hash)]
104    pub struct CKSyncEngineEvent;
105);
106
107unsafe impl Send for CKSyncEngineEvent {}
108
109unsafe impl Sync for CKSyncEngineEvent {}
110
111unsafe impl NSObjectProtocol for CKSyncEngineEvent {}
112
113impl CKSyncEngineEvent {
114    extern_methods!(
115        #[unsafe(method(type))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn r#type(&self) -> CKSyncEngineEventType;
118
119        #[unsafe(method(stateUpdateEvent))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn stateUpdateEvent(&self) -> Retained<CKSyncEngineStateUpdateEvent>;
122
123        #[unsafe(method(accountChangeEvent))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn accountChangeEvent(&self) -> Retained<CKSyncEngineAccountChangeEvent>;
126
127        #[unsafe(method(fetchedDatabaseChangesEvent))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn fetchedDatabaseChangesEvent(
130            &self,
131        ) -> Retained<CKSyncEngineFetchedDatabaseChangesEvent>;
132
133        #[unsafe(method(fetchedRecordZoneChangesEvent))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn fetchedRecordZoneChangesEvent(
136            &self,
137        ) -> Retained<CKSyncEngineFetchedRecordZoneChangesEvent>;
138
139        #[unsafe(method(sentDatabaseChangesEvent))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn sentDatabaseChangesEvent(
142            &self,
143        ) -> Retained<CKSyncEngineSentDatabaseChangesEvent>;
144
145        #[unsafe(method(sentRecordZoneChangesEvent))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn sentRecordZoneChangesEvent(
148            &self,
149        ) -> Retained<CKSyncEngineSentRecordZoneChangesEvent>;
150
151        #[unsafe(method(willFetchChangesEvent))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn willFetchChangesEvent(&self) -> Retained<CKSyncEngineWillFetchChangesEvent>;
154
155        #[unsafe(method(willFetchRecordZoneChangesEvent))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn willFetchRecordZoneChangesEvent(
158            &self,
159        ) -> Retained<CKSyncEngineWillFetchRecordZoneChangesEvent>;
160
161        #[unsafe(method(didFetchRecordZoneChangesEvent))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn didFetchRecordZoneChangesEvent(
164            &self,
165        ) -> Retained<CKSyncEngineDidFetchRecordZoneChangesEvent>;
166
167        #[unsafe(method(didFetchChangesEvent))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn didFetchChangesEvent(&self) -> Retained<CKSyncEngineDidFetchChangesEvent>;
170
171        #[unsafe(method(willSendChangesEvent))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn willSendChangesEvent(&self) -> Retained<CKSyncEngineWillSendChangesEvent>;
174
175        #[unsafe(method(didSendChangesEvent))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn didSendChangesEvent(&self) -> Retained<CKSyncEngineDidSendChangesEvent>;
178
179        #[unsafe(method(init))]
180        #[unsafe(method_family = init)]
181        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
182
183        #[unsafe(method(new))]
184        #[unsafe(method_family = new)]
185        pub unsafe fn new() -> Retained<Self>;
186    );
187}
188
189extern_class!(
190    /// The sync engine state was updated, and you should persist it locally.
191    ///
192    /// In order to function properly and efficiently, `CKSyncEngine` tracks some state internally.
193    /// When the sync engine state changes, it will give you the latest serialized version in a `CKSyncEngineStateUpdateEvent`.
194    /// This event will happen occasionally when the sync engine modifies the state internally during normal sync operation.
195    /// This event will also happen when you change the state yourself.
196    ///
197    /// The sync engine does not persist this state to disk, so you need to persist it in alongside your own local data.
198    /// The next time your process launches, use this latest state serialization in ``CKSyncEngineConfiguration/stateSerialization`` to initialize your sync engine.
199    ///
200    /// This state is directly tied to the changes you fetch and send with the sync engine.
201    /// You should ensure that any changes fetched prior to receiving this state are also persisted alongside this state.
202    ///
203    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginestateupdateevent?language=objc)
204    #[unsafe(super(CKSyncEngineEvent, NSObject))]
205    #[derive(Debug, PartialEq, Eq, Hash)]
206    pub struct CKSyncEngineStateUpdateEvent;
207);
208
209unsafe impl Send for CKSyncEngineStateUpdateEvent {}
210
211unsafe impl Sync for CKSyncEngineStateUpdateEvent {}
212
213unsafe impl NSObjectProtocol for CKSyncEngineStateUpdateEvent {}
214
215impl CKSyncEngineStateUpdateEvent {
216    extern_methods!(
217        #[cfg(feature = "CKSyncEngineState")]
218        #[unsafe(method(stateSerialization))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn stateSerialization(&self) -> Retained<CKSyncEngineStateSerialization>;
221    );
222}
223
224/// Methods declared on superclass `CKSyncEngineEvent`.
225impl CKSyncEngineStateUpdateEvent {
226    extern_methods!(
227        #[unsafe(method(init))]
228        #[unsafe(method_family = init)]
229        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
230
231        #[unsafe(method(new))]
232        #[unsafe(method_family = new)]
233        pub unsafe fn new() -> Retained<Self>;
234    );
235}
236
237/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncengineaccountchangetype?language=objc)
238// NS_ENUM
239#[repr(transparent)]
240#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
241pub struct CKSyncEngineAccountChangeType(pub NSInteger);
242impl CKSyncEngineAccountChangeType {
243    /// The user signed in to an account.
244    ///
245    /// If you already have data stored locally, you have a few options:
246    ///
247    /// - Merge the local data with the newly-signed-in account's data.
248    /// - Keep the local data separate from cloud-synced data (e.g. a separate "local account").
249    /// - Delete the local data.
250    /// - Prompt the user to make the decision.
251    #[doc(alias = "CKSyncEngineAccountChangeTypeSignIn")]
252    pub const SignIn: Self = Self(0);
253    /// The user signed out of their account.
254    ///
255    /// You should delete any locally-stored data for the previous account.
256    #[doc(alias = "CKSyncEngineAccountChangeTypeSignOut")]
257    pub const SignOut: Self = Self(1);
258    /// The user switched from one account to another.
259    /// This might happen if the user signs out and in to a new account while your application is quit.
260    ///
261    /// You should delete any locally-stored data for the previous account.
262    #[doc(alias = "CKSyncEngineAccountChangeTypeSwitchAccounts")]
263    pub const SwitchAccounts: Self = Self(2);
264}
265
266unsafe impl Encode for CKSyncEngineAccountChangeType {
267    const ENCODING: Encoding = NSInteger::ENCODING;
268}
269
270unsafe impl RefEncode for CKSyncEngineAccountChangeType {
271    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
272}
273
274extern_class!(
275    /// The user signed in or out of their account.
276    ///
277    /// The sync engine automatically listens for account changes, and it will send this event when the user signs in or out.
278    /// It's your responsibility to react appropriately to this change and update your local persistence.
279    ///
280    /// When the logged-in account changes, the sync engine will reset its internal state under the hood.
281    /// This means that it will clear any pending database or record zone changes that you may have added.
282    ///
283    /// Note that it's possible the account changes multiple times while your app is quit.
284    /// If this happens, you will only receive one account change event representing the transition between the last known state and the current state.
285    ///
286    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncengineaccountchangeevent?language=objc)
287    #[unsafe(super(CKSyncEngineEvent, NSObject))]
288    #[derive(Debug, PartialEq, Eq, Hash)]
289    pub struct CKSyncEngineAccountChangeEvent;
290);
291
292unsafe impl Send for CKSyncEngineAccountChangeEvent {}
293
294unsafe impl Sync for CKSyncEngineAccountChangeEvent {}
295
296unsafe impl NSObjectProtocol for CKSyncEngineAccountChangeEvent {}
297
298impl CKSyncEngineAccountChangeEvent {
299    extern_methods!(
300        /// The type of account change that occurred.
301        #[unsafe(method(changeType))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn changeType(&self) -> CKSyncEngineAccountChangeType;
304
305        #[cfg(feature = "CKRecordID")]
306        /// The user record ID for the previous user.
307        ///
308        /// If the user just signed in, this will be `nil`.
309        /// If the user signed out or switched accounts, this will be the old account.
310        #[unsafe(method(previousUser))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn previousUser(&self) -> Option<Retained<CKRecordID>>;
313
314        #[cfg(feature = "CKRecordID")]
315        /// The user record ID for the current user.
316        ///
317        /// If the user just signed in or switched accounts, this will be the new user record ID.
318        /// If the user signed out, this will be `nil`.
319        #[unsafe(method(currentUser))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn currentUser(&self) -> Option<Retained<CKRecordID>>;
322    );
323}
324
325/// Methods declared on superclass `CKSyncEngineEvent`.
326impl CKSyncEngineAccountChangeEvent {
327    extern_methods!(
328        #[unsafe(method(init))]
329        #[unsafe(method_family = init)]
330        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
331
332        #[unsafe(method(new))]
333        #[unsafe(method_family = new)]
334        pub unsafe fn new() -> Retained<Self>;
335    );
336}
337
338extern_class!(
339    /// A batch of database changes was fetched from the server.
340    ///
341    /// If there are a lot of new changes on the server, then you might receive many of these events in a row.
342    ///
343    /// The ordering of fetched changes is not guaranteed, but changes will typically be fetched from oldest to newest.
344    ///
345    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginefetcheddatabasechangesevent?language=objc)
346    #[unsafe(super(CKSyncEngineEvent, NSObject))]
347    #[derive(Debug, PartialEq, Eq, Hash)]
348    pub struct CKSyncEngineFetchedDatabaseChangesEvent;
349);
350
351unsafe impl Send for CKSyncEngineFetchedDatabaseChangesEvent {}
352
353unsafe impl Sync for CKSyncEngineFetchedDatabaseChangesEvent {}
354
355unsafe impl NSObjectProtocol for CKSyncEngineFetchedDatabaseChangesEvent {}
356
357impl CKSyncEngineFetchedDatabaseChangesEvent {
358    extern_methods!(
359        #[cfg(feature = "CKRecordZone")]
360        #[unsafe(method(modifications))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn modifications(&self) -> Retained<NSArray<CKRecordZone>>;
363
364        #[unsafe(method(deletions))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn deletions(&self) -> Retained<NSArray<CKSyncEngineFetchedZoneDeletion>>;
367    );
368}
369
370/// Methods declared on superclass `CKSyncEngineEvent`.
371impl CKSyncEngineFetchedDatabaseChangesEvent {
372    extern_methods!(
373        #[unsafe(method(init))]
374        #[unsafe(method_family = init)]
375        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
376
377        #[unsafe(method(new))]
378        #[unsafe(method_family = new)]
379        pub unsafe fn new() -> Retained<Self>;
380    );
381}
382
383extern_class!(
384    /// A batch of record zone changes was fetched from the server.
385    ///
386    /// If there are a lot of new changes on the server, then you might receive many of these events in a row.
387    ///
388    /// The ordering of fetched changes is not guaranteed, but changes will typically be fetched from oldest to newest.
389    ///
390    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginefetchedrecordzonechangesevent?language=objc)
391    #[unsafe(super(CKSyncEngineEvent, NSObject))]
392    #[derive(Debug, PartialEq, Eq, Hash)]
393    pub struct CKSyncEngineFetchedRecordZoneChangesEvent;
394);
395
396unsafe impl Send for CKSyncEngineFetchedRecordZoneChangesEvent {}
397
398unsafe impl Sync for CKSyncEngineFetchedRecordZoneChangesEvent {}
399
400unsafe impl NSObjectProtocol for CKSyncEngineFetchedRecordZoneChangesEvent {}
401
402impl CKSyncEngineFetchedRecordZoneChangesEvent {
403    extern_methods!(
404        #[cfg(feature = "CKRecord")]
405        #[unsafe(method(modifications))]
406        #[unsafe(method_family = none)]
407        pub unsafe fn modifications(&self) -> Retained<NSArray<CKRecord>>;
408
409        #[unsafe(method(deletions))]
410        #[unsafe(method_family = none)]
411        pub unsafe fn deletions(&self) -> Retained<NSArray<CKSyncEngineFetchedRecordDeletion>>;
412    );
413}
414
415/// Methods declared on superclass `CKSyncEngineEvent`.
416impl CKSyncEngineFetchedRecordZoneChangesEvent {
417    extern_methods!(
418        #[unsafe(method(init))]
419        #[unsafe(method_family = init)]
420        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
421
422        #[unsafe(method(new))]
423        #[unsafe(method_family = new)]
424        pub unsafe fn new() -> Retained<Self>;
425    );
426}
427
428extern_class!(
429    /// The sync engine finished sending a batch of database changes to the server.
430    ///
431    /// If a change failed, try to resolve the issue causing the error and make the change again if necessary.
432    ///
433    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginesentdatabasechangesevent?language=objc)
434    #[unsafe(super(CKSyncEngineEvent, NSObject))]
435    #[derive(Debug, PartialEq, Eq, Hash)]
436    pub struct CKSyncEngineSentDatabaseChangesEvent;
437);
438
439unsafe impl Send for CKSyncEngineSentDatabaseChangesEvent {}
440
441unsafe impl Sync for CKSyncEngineSentDatabaseChangesEvent {}
442
443unsafe impl NSObjectProtocol for CKSyncEngineSentDatabaseChangesEvent {}
444
445impl CKSyncEngineSentDatabaseChangesEvent {
446    extern_methods!(
447        #[cfg(feature = "CKRecordZone")]
448        #[unsafe(method(savedZones))]
449        #[unsafe(method_family = none)]
450        pub unsafe fn savedZones(&self) -> Retained<NSArray<CKRecordZone>>;
451
452        #[unsafe(method(failedZoneSaves))]
453        #[unsafe(method_family = none)]
454        pub unsafe fn failedZoneSaves(&self) -> Retained<NSArray<CKSyncEngineFailedZoneSave>>;
455
456        #[cfg(feature = "CKRecordZoneID")]
457        #[unsafe(method(deletedZoneIDs))]
458        #[unsafe(method_family = none)]
459        pub unsafe fn deletedZoneIDs(&self) -> Retained<NSArray<CKRecordZoneID>>;
460
461        #[cfg(feature = "CKRecordZoneID")]
462        #[unsafe(method(failedZoneDeletes))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn failedZoneDeletes(&self) -> Retained<NSDictionary<CKRecordZoneID, NSError>>;
465    );
466}
467
468/// Methods declared on superclass `CKSyncEngineEvent`.
469impl CKSyncEngineSentDatabaseChangesEvent {
470    extern_methods!(
471        #[unsafe(method(init))]
472        #[unsafe(method_family = init)]
473        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
474
475        #[unsafe(method(new))]
476        #[unsafe(method_family = new)]
477        pub unsafe fn new() -> Retained<Self>;
478    );
479}
480
481extern_class!(
482    /// The sync engine finished sending a batch of record zone changes to the server.
483    ///
484    /// If a record save succeeded, you should encode the system fields of this record to use the next time you save. See `encodeSystemFields` on `CKRecord`.
485    ///
486    /// If a record deletion succeeded, you should remove any local system fields for that record.
487    ///
488    /// If the record change failed, try to resolve the issue causing the error and save the record again if necessary.
489    ///
490    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginesentrecordzonechangesevent?language=objc)
491    #[unsafe(super(CKSyncEngineEvent, NSObject))]
492    #[derive(Debug, PartialEq, Eq, Hash)]
493    pub struct CKSyncEngineSentRecordZoneChangesEvent;
494);
495
496unsafe impl Send for CKSyncEngineSentRecordZoneChangesEvent {}
497
498unsafe impl Sync for CKSyncEngineSentRecordZoneChangesEvent {}
499
500unsafe impl NSObjectProtocol for CKSyncEngineSentRecordZoneChangesEvent {}
501
502impl CKSyncEngineSentRecordZoneChangesEvent {
503    extern_methods!(
504        #[cfg(feature = "CKRecord")]
505        #[unsafe(method(savedRecords))]
506        #[unsafe(method_family = none)]
507        pub unsafe fn savedRecords(&self) -> Retained<NSArray<CKRecord>>;
508
509        #[unsafe(method(failedRecordSaves))]
510        #[unsafe(method_family = none)]
511        pub unsafe fn failedRecordSaves(&self) -> Retained<NSArray<CKSyncEngineFailedRecordSave>>;
512
513        #[cfg(feature = "CKRecordID")]
514        #[unsafe(method(deletedRecordIDs))]
515        #[unsafe(method_family = none)]
516        pub unsafe fn deletedRecordIDs(&self) -> Retained<NSArray<CKRecordID>>;
517
518        #[cfg(feature = "CKRecordID")]
519        #[unsafe(method(failedRecordDeletes))]
520        #[unsafe(method_family = none)]
521        pub unsafe fn failedRecordDeletes(&self) -> Retained<NSDictionary<CKRecordID, NSError>>;
522    );
523}
524
525/// Methods declared on superclass `CKSyncEngineEvent`.
526impl CKSyncEngineSentRecordZoneChangesEvent {
527    extern_methods!(
528        #[unsafe(method(init))]
529        #[unsafe(method_family = init)]
530        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
531
532        #[unsafe(method(new))]
533        #[unsafe(method_family = new)]
534        pub unsafe fn new() -> Retained<Self>;
535    );
536}
537
538extern_class!(
539    /// The sync engine is about to fetch changes from the server.
540    ///
541    /// This might be a good signal to prepare your local data store for incoming changes if necessary.
542    /// The changes themselves will be delivered via `CKSyncEngineFetchedDatabaseChanges` and `CKSyncEngineFetchedRecordZoneChangesEvent`.
543    ///
544    /// Note that this event might not always occur every time you call `fetchChanges`.
545    /// For example, if you call `fetchChanges` concurrently while the engine is already fetching changes, this event might not be sent.
546    /// Similarly, if there's no logged-in account, the engine might short-circuit the call to `fetchChanges`, and this event won't be sent.
547    ///
548    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginewillfetchchangesevent?language=objc)
549    #[unsafe(super(CKSyncEngineEvent, NSObject))]
550    #[derive(Debug, PartialEq, Eq, Hash)]
551    pub struct CKSyncEngineWillFetchChangesEvent;
552);
553
554unsafe impl Send for CKSyncEngineWillFetchChangesEvent {}
555
556unsafe impl Sync for CKSyncEngineWillFetchChangesEvent {}
557
558unsafe impl NSObjectProtocol for CKSyncEngineWillFetchChangesEvent {}
559
560impl CKSyncEngineWillFetchChangesEvent {
561    extern_methods!(
562        #[cfg(feature = "CKSyncEngine")]
563        #[unsafe(method(context))]
564        #[unsafe(method_family = none)]
565        pub unsafe fn context(&self) -> Retained<CKSyncEngineFetchChangesContext>;
566    );
567}
568
569/// Methods declared on superclass `CKSyncEngineEvent`.
570impl CKSyncEngineWillFetchChangesEvent {
571    extern_methods!(
572        #[unsafe(method(init))]
573        #[unsafe(method_family = init)]
574        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
575
576        #[unsafe(method(new))]
577        #[unsafe(method_family = new)]
578        pub unsafe fn new() -> Retained<Self>;
579    );
580}
581
582extern_class!(
583    /// The sync engine is about to fetch record zone changes from the server for a specific zone.
584    ///
585    /// This might be a good signal to prepare your local data store for incoming changes if necessary.
586    ///
587    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginewillfetchrecordzonechangesevent?language=objc)
588    #[unsafe(super(CKSyncEngineEvent, NSObject))]
589    #[derive(Debug, PartialEq, Eq, Hash)]
590    pub struct CKSyncEngineWillFetchRecordZoneChangesEvent;
591);
592
593unsafe impl Send for CKSyncEngineWillFetchRecordZoneChangesEvent {}
594
595unsafe impl Sync for CKSyncEngineWillFetchRecordZoneChangesEvent {}
596
597unsafe impl NSObjectProtocol for CKSyncEngineWillFetchRecordZoneChangesEvent {}
598
599impl CKSyncEngineWillFetchRecordZoneChangesEvent {
600    extern_methods!(
601        #[cfg(feature = "CKRecordZoneID")]
602        #[unsafe(method(zoneID))]
603        #[unsafe(method_family = none)]
604        pub unsafe fn zoneID(&self) -> Retained<CKRecordZoneID>;
605    );
606}
607
608/// Methods declared on superclass `CKSyncEngineEvent`.
609impl CKSyncEngineWillFetchRecordZoneChangesEvent {
610    extern_methods!(
611        #[unsafe(method(init))]
612        #[unsafe(method_family = init)]
613        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
614
615        #[unsafe(method(new))]
616        #[unsafe(method_family = new)]
617        pub unsafe fn new() -> Retained<Self>;
618    );
619}
620
621extern_class!(
622    /// The sync engine finished fetching record zone changes from the server for a specific zone.
623    ///
624    /// This might be a good signal to perform any post-processing tasks on a per-zone basis if necessary.
625    ///
626    /// You should receive one `CKSyncEngineDidFetchRecordZoneChangesEvent` for each `CKSyncEngineWillFetchRecordZoneChangesEvent`.
627    ///
628    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginedidfetchrecordzonechangesevent?language=objc)
629    #[unsafe(super(CKSyncEngineEvent, NSObject))]
630    #[derive(Debug, PartialEq, Eq, Hash)]
631    pub struct CKSyncEngineDidFetchRecordZoneChangesEvent;
632);
633
634unsafe impl Send for CKSyncEngineDidFetchRecordZoneChangesEvent {}
635
636unsafe impl Sync for CKSyncEngineDidFetchRecordZoneChangesEvent {}
637
638unsafe impl NSObjectProtocol for CKSyncEngineDidFetchRecordZoneChangesEvent {}
639
640impl CKSyncEngineDidFetchRecordZoneChangesEvent {
641    extern_methods!(
642        #[cfg(feature = "CKRecordZoneID")]
643        #[unsafe(method(zoneID))]
644        #[unsafe(method_family = none)]
645        pub unsafe fn zoneID(&self) -> Retained<CKRecordZoneID>;
646
647        #[unsafe(method(error))]
648        #[unsafe(method_family = none)]
649        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
650    );
651}
652
653/// Methods declared on superclass `CKSyncEngineEvent`.
654impl CKSyncEngineDidFetchRecordZoneChangesEvent {
655    extern_methods!(
656        #[unsafe(method(init))]
657        #[unsafe(method_family = init)]
658        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
659
660        #[unsafe(method(new))]
661        #[unsafe(method_family = new)]
662        pub unsafe fn new() -> Retained<Self>;
663    );
664}
665
666extern_class!(
667    /// The sync engine finished fetching changes from the server.
668    ///
669    /// This might be a good signal to perform any post-processing tasks required after persisting fetched changes to disk.
670    ///
671    /// You should receive one `CKSyncEngineDidFetchChangesEvent` for each `CKSyncEngineWillFetchChangesEvent`.
672    ///
673    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginedidfetchchangesevent?language=objc)
674    #[unsafe(super(CKSyncEngineEvent, NSObject))]
675    #[derive(Debug, PartialEq, Eq, Hash)]
676    pub struct CKSyncEngineDidFetchChangesEvent;
677);
678
679unsafe impl Send for CKSyncEngineDidFetchChangesEvent {}
680
681unsafe impl Sync for CKSyncEngineDidFetchChangesEvent {}
682
683unsafe impl NSObjectProtocol for CKSyncEngineDidFetchChangesEvent {}
684
685impl CKSyncEngineDidFetchChangesEvent {
686    extern_methods!(
687        #[cfg(feature = "CKSyncEngine")]
688        #[unsafe(method(context))]
689        #[unsafe(method_family = none)]
690        pub unsafe fn context(&self) -> Retained<CKSyncEngineFetchChangesContext>;
691    );
692}
693
694/// Methods declared on superclass `CKSyncEngineEvent`.
695impl CKSyncEngineDidFetchChangesEvent {
696    extern_methods!(
697        #[unsafe(method(init))]
698        #[unsafe(method_family = init)]
699        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
700
701        #[unsafe(method(new))]
702        #[unsafe(method_family = new)]
703        pub unsafe fn new() -> Retained<Self>;
704    );
705}
706
707extern_class!(
708    /// The sync engine is about to send changes to the server.
709    ///
710    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginewillsendchangesevent?language=objc)
711    #[unsafe(super(CKSyncEngineEvent, NSObject))]
712    #[derive(Debug, PartialEq, Eq, Hash)]
713    pub struct CKSyncEngineWillSendChangesEvent;
714);
715
716unsafe impl Send for CKSyncEngineWillSendChangesEvent {}
717
718unsafe impl Sync for CKSyncEngineWillSendChangesEvent {}
719
720unsafe impl NSObjectProtocol for CKSyncEngineWillSendChangesEvent {}
721
722impl CKSyncEngineWillSendChangesEvent {
723    extern_methods!(
724        #[cfg(feature = "CKSyncEngine")]
725        #[unsafe(method(context))]
726        #[unsafe(method_family = none)]
727        pub unsafe fn context(&self) -> Retained<CKSyncEngineSendChangesContext>;
728    );
729}
730
731/// Methods declared on superclass `CKSyncEngineEvent`.
732impl CKSyncEngineWillSendChangesEvent {
733    extern_methods!(
734        #[unsafe(method(init))]
735        #[unsafe(method_family = init)]
736        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
737
738        #[unsafe(method(new))]
739        #[unsafe(method_family = new)]
740        pub unsafe fn new() -> Retained<Self>;
741    );
742}
743
744extern_class!(
745    /// The sync engine finished sending changes to the server.
746    ///
747    /// You should receive one `CKSyncEngineDidSendChangesEvent` for every `CKSyncEngineWillSendChangesEvent`.
748    ///
749    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginedidsendchangesevent?language=objc)
750    #[unsafe(super(CKSyncEngineEvent, NSObject))]
751    #[derive(Debug, PartialEq, Eq, Hash)]
752    pub struct CKSyncEngineDidSendChangesEvent;
753);
754
755unsafe impl Send for CKSyncEngineDidSendChangesEvent {}
756
757unsafe impl Sync for CKSyncEngineDidSendChangesEvent {}
758
759unsafe impl NSObjectProtocol for CKSyncEngineDidSendChangesEvent {}
760
761impl CKSyncEngineDidSendChangesEvent {
762    extern_methods!(
763        #[cfg(feature = "CKSyncEngine")]
764        #[unsafe(method(context))]
765        #[unsafe(method_family = none)]
766        pub unsafe fn context(&self) -> Retained<CKSyncEngineSendChangesContext>;
767    );
768}
769
770/// Methods declared on superclass `CKSyncEngineEvent`.
771impl CKSyncEngineDidSendChangesEvent {
772    extern_methods!(
773        #[unsafe(method(init))]
774        #[unsafe(method_family = init)]
775        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
776
777        #[unsafe(method(new))]
778        #[unsafe(method_family = new)]
779        pub unsafe fn new() -> Retained<Self>;
780    );
781}
782
783extern_class!(
784    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginefetchedrecorddeletion?language=objc)
785    #[unsafe(super(NSObject))]
786    #[derive(Debug, PartialEq, Eq, Hash)]
787    pub struct CKSyncEngineFetchedRecordDeletion;
788);
789
790unsafe impl Send for CKSyncEngineFetchedRecordDeletion {}
791
792unsafe impl Sync for CKSyncEngineFetchedRecordDeletion {}
793
794unsafe impl NSObjectProtocol for CKSyncEngineFetchedRecordDeletion {}
795
796impl CKSyncEngineFetchedRecordDeletion {
797    extern_methods!(
798        #[unsafe(method(init))]
799        #[unsafe(method_family = init)]
800        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
801
802        #[unsafe(method(new))]
803        #[unsafe(method_family = new)]
804        pub unsafe fn new() -> Retained<Self>;
805
806        #[cfg(feature = "CKRecordID")]
807        #[unsafe(method(recordID))]
808        #[unsafe(method_family = none)]
809        pub unsafe fn recordID(&self) -> Retained<CKRecordID>;
810
811        #[cfg(feature = "CKRecord")]
812        #[unsafe(method(recordType))]
813        #[unsafe(method_family = none)]
814        pub unsafe fn recordType(&self) -> Retained<CKRecordType>;
815    );
816}
817
818/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginezonedeletionreason?language=objc)
819// NS_ENUM
820#[repr(transparent)]
821#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
822pub struct CKSyncEngineZoneDeletionReason(pub NSInteger);
823impl CKSyncEngineZoneDeletionReason {
824    /// A deletion from your software.
825    #[doc(alias = "CKSyncEngineZoneDeletionReasonDeleted")]
826    pub const Deleted: Self = Self(0);
827    /// A deletion from the user via the iCloud storage UI.
828    /// This is an indication that the user wanted all data deleted, so local cached data should be wiped and not re-uploaded to the server.
829    #[doc(alias = "CKSyncEngineZoneDeletionReasonPurged")]
830    pub const Purged: Self = Self(1);
831    /// The user chose to reset all encrypted data for their account.
832    /// This is an indication that the user had to reset encrypted data during account recovery, so local cached data should be re-uploaded to the server to minimize data loss.
833    #[doc(alias = "CKSyncEngineZoneDeletionReasonEncryptedDataReset")]
834    pub const EncryptedDataReset: Self = Self(2);
835}
836
837unsafe impl Encode for CKSyncEngineZoneDeletionReason {
838    const ENCODING: Encoding = NSInteger::ENCODING;
839}
840
841unsafe impl RefEncode for CKSyncEngineZoneDeletionReason {
842    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
843}
844
845extern_class!(
846    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginefetchedzonedeletion?language=objc)
847    #[unsafe(super(NSObject))]
848    #[derive(Debug, PartialEq, Eq, Hash)]
849    pub struct CKSyncEngineFetchedZoneDeletion;
850);
851
852unsafe impl Send for CKSyncEngineFetchedZoneDeletion {}
853
854unsafe impl Sync for CKSyncEngineFetchedZoneDeletion {}
855
856unsafe impl NSObjectProtocol for CKSyncEngineFetchedZoneDeletion {}
857
858impl CKSyncEngineFetchedZoneDeletion {
859    extern_methods!(
860        #[unsafe(method(init))]
861        #[unsafe(method_family = init)]
862        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
863
864        #[unsafe(method(new))]
865        #[unsafe(method_family = new)]
866        pub unsafe fn new() -> Retained<Self>;
867
868        #[cfg(feature = "CKRecordZoneID")]
869        #[unsafe(method(zoneID))]
870        #[unsafe(method_family = none)]
871        pub unsafe fn zoneID(&self) -> Retained<CKRecordZoneID>;
872
873        #[unsafe(method(reason))]
874        #[unsafe(method_family = none)]
875        pub unsafe fn reason(&self) -> CKSyncEngineZoneDeletionReason;
876    );
877}
878
879extern_class!(
880    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginefailedrecordsave?language=objc)
881    #[unsafe(super(NSObject))]
882    #[derive(Debug, PartialEq, Eq, Hash)]
883    pub struct CKSyncEngineFailedRecordSave;
884);
885
886unsafe impl Send for CKSyncEngineFailedRecordSave {}
887
888unsafe impl Sync for CKSyncEngineFailedRecordSave {}
889
890unsafe impl NSObjectProtocol for CKSyncEngineFailedRecordSave {}
891
892impl CKSyncEngineFailedRecordSave {
893    extern_methods!(
894        #[unsafe(method(init))]
895        #[unsafe(method_family = init)]
896        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
897
898        #[unsafe(method(new))]
899        #[unsafe(method_family = new)]
900        pub unsafe fn new() -> Retained<Self>;
901
902        #[cfg(feature = "CKRecord")]
903        #[unsafe(method(record))]
904        #[unsafe(method_family = none)]
905        pub unsafe fn record(&self) -> Retained<CKRecord>;
906
907        #[unsafe(method(error))]
908        #[unsafe(method_family = none)]
909        pub unsafe fn error(&self) -> Retained<NSError>;
910    );
911}
912
913extern_class!(
914    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginefailedzonesave?language=objc)
915    #[unsafe(super(NSObject))]
916    #[derive(Debug, PartialEq, Eq, Hash)]
917    pub struct CKSyncEngineFailedZoneSave;
918);
919
920unsafe impl Send for CKSyncEngineFailedZoneSave {}
921
922unsafe impl Sync for CKSyncEngineFailedZoneSave {}
923
924unsafe impl NSObjectProtocol for CKSyncEngineFailedZoneSave {}
925
926impl CKSyncEngineFailedZoneSave {
927    extern_methods!(
928        #[unsafe(method(init))]
929        #[unsafe(method_family = init)]
930        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
931
932        #[unsafe(method(new))]
933        #[unsafe(method_family = new)]
934        pub unsafe fn new() -> Retained<Self>;
935
936        #[cfg(feature = "CKRecordZone")]
937        #[unsafe(method(recordZone))]
938        #[unsafe(method_family = none)]
939        pub unsafe fn recordZone(&self) -> Retained<CKRecordZone>;
940
941        #[unsafe(method(error))]
942        #[unsafe(method_family = none)]
943        pub unsafe fn error(&self) -> Retained<NSError>;
944    );
945}