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