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