objc2_cloud_kit/generated/
CKSyncEngineState.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// An object that tracks some state required for proper and efficient operation of ``CKSyncEngine-5sie5``.
12    ///
13    /// ``CKSyncEngine-5sie5`` needs to track several things in order to properly sync.
14    /// For example, it needs to remember the last server change tokens for your database and zones.
15    /// It also needs to keep track of things like the last known user record ID and other various pieces of state.
16    ///
17    /// A lot of this state is hidden internally, but some of it you can control.
18    ///
19    /// ## Pending changes
20    ///
21    /// One of the main things you can control is the list of pending changes to send to the server.
22    /// You can control these by calling functions like ``addPendingDatabaseChanges:`` and ``addPendingRecordZoneChanges:``.
23    /// When you add new pending changes, the sync engine will automatically schedule a task to sync with the server.
24    ///
25    /// ## State serialization
26    ///
27    /// ``CKSyncEngine-5sie5`` will occasionally update its state in the background.
28    /// When it updates its state, your delegate will receive a ``CKSyncEngineStateUpdateEvent``.
29    ///
30    /// This event will contain a ``CKSyncEngineStateSerialization``, which you should persist locally.
31    /// The next time your process launches, you initialize your sync engine with the last state serialization you received.
32    ///
33    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginestate?language=objc)
34    #[unsafe(super(NSObject))]
35    #[derive(Debug, PartialEq, Eq, Hash)]
36    pub struct CKSyncEngineState;
37);
38
39unsafe impl Send for CKSyncEngineState {}
40
41unsafe impl Sync for CKSyncEngineState {}
42
43extern_conformance!(
44    unsafe impl NSObjectProtocol for CKSyncEngineState {}
45);
46
47impl CKSyncEngineState {
48    extern_methods!(
49        #[unsafe(method(init))]
50        #[unsafe(method_family = init)]
51        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
52
53        #[unsafe(method(new))]
54        #[unsafe(method_family = new)]
55        pub unsafe fn new() -> Retained<Self>;
56
57        /// A list of record changes that need to be sent to the server.
58        ///
59        /// ``CKSyncEngine-5sie5`` provides the convenience of tracking your pending record zone changes.
60        /// When the user makes some changes that need to be sent to the server, you can track them in this list.
61        /// Then, you can use this list when creating your next ``CKSyncEngineRecordZoneChangeBatch`` in your ``CKSyncEngineDelegate-1q7g8``.
62        ///
63        /// The sync engine will ensure consistency and deduplicate these pending changes under the hood.
64        /// For example, if you add a pending save for record A, then record B, then record A again, this will result in a list of `[saveRecordA, saveRecordB]`.
65        /// Similarly, if you add a pending save for record A, then add a pending delete for the same record A, this will result in a single pending change of `[deleteRecordA]`.
66        ///
67        /// The sync engine will manage this list while it sends changes to the server.
68        /// For example, when it successfully saves a record, it will remove that change from this list.
69        /// If it fails to send a change due to some retryable error (e.g. a network failure), it will keep that change in this list.
70        ///
71        /// If you'd prefer to track pending changes yourself, you can use ``CKSyncEngine/State/hasPendingUntrackedChanges`` instead.
72        #[unsafe(method(pendingRecordZoneChanges))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn pendingRecordZoneChanges(
75            &self,
76        ) -> Retained<NSArray<CKSyncEnginePendingRecordZoneChange>>;
77
78        /// A list of database changes that need to be sent to the server, similar to `pendingRecordZoneChanges`.
79        #[unsafe(method(pendingDatabaseChanges))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn pendingDatabaseChanges(
82            &self,
83        ) -> Retained<NSArray<CKSyncEnginePendingDatabaseChange>>;
84
85        /// This represents whether or not you have pending changes to send to the server that aren't tracked in ``CKSyncEngine/State/pendingRecordZoneChanges``.
86        /// This is useful if you want to track pending changes in your own local database instead of the sync engine state.
87        ///
88        /// When this property is set, the sync engine will automatically schedule a sync.
89        /// When the sync task runs, it will ask your delegate for pending changes in ``CKSyncEngineDelegate/nextRecordZoneChangeBatch(_:syncEngine:)``.
90        #[unsafe(method(hasPendingUntrackedChanges))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn hasPendingUntrackedChanges(&self) -> bool;
93
94        /// Setter for [`hasPendingUntrackedChanges`][Self::hasPendingUntrackedChanges].
95        #[unsafe(method(setHasPendingUntrackedChanges:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn setHasPendingUntrackedChanges(&self, has_pending_untracked_changes: bool);
98
99        #[cfg(feature = "CKRecordZoneID")]
100        /// The list of zone IDs that have new changes to fetch from the server.
101        /// ``CKSyncEngine-5sie5`` keeps track of these zones and will update this list as it receives new information.
102        #[unsafe(method(zoneIDsWithUnfetchedServerChanges))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn zoneIDsWithUnfetchedServerChanges(&self)
105            -> Retained<NSArray<CKRecordZoneID>>;
106
107        /// Adds to the list of pending record zone changes.
108        ///
109        /// When you add a new pending change, the sync engine will automatically schedule a sync task.
110        ///
111        /// The sync engine will ensure consistency and deduplicate these changes under the hood.
112        #[unsafe(method(addPendingRecordZoneChanges:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn addPendingRecordZoneChanges(
115            &self,
116            changes: &NSArray<CKSyncEnginePendingRecordZoneChange>,
117        );
118
119        /// Removes from the list of pending record zone changes.
120        #[unsafe(method(removePendingRecordZoneChanges:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn removePendingRecordZoneChanges(
123            &self,
124            changes: &NSArray<CKSyncEnginePendingRecordZoneChange>,
125        );
126
127        /// Adds to the list of pending database changes.
128        ///
129        /// When you add a new pending change, the sync engine will automatically schedule a sync task.
130        ///
131        /// The sync engine will ensure consistency and deduplicate these changes under the hood.
132        #[unsafe(method(addPendingDatabaseChanges:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn addPendingDatabaseChanges(
135            &self,
136            changes: &NSArray<CKSyncEnginePendingDatabaseChange>,
137        );
138
139        /// Removes from the list of pending database changes.
140        #[unsafe(method(removePendingDatabaseChanges:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn removePendingDatabaseChanges(
143            &self,
144            changes: &NSArray<CKSyncEnginePendingDatabaseChange>,
145        );
146    );
147}
148
149extern_class!(
150    /// A serialized representation of a ``CKSyncEngineState``.
151    ///
152    /// This will be passed to your delegate via ``CKSyncEngine/Event/StateUpdate``.
153    /// You should use `NSSecureCoding` to persist this locally alongside your other data and use it the next time you initialize your sync engine.
154    ///
155    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginestateserialization?language=objc)
156    #[unsafe(super(NSObject))]
157    #[derive(Debug, PartialEq, Eq, Hash)]
158    pub struct CKSyncEngineStateSerialization;
159);
160
161unsafe impl Send for CKSyncEngineStateSerialization {}
162
163unsafe impl Sync for CKSyncEngineStateSerialization {}
164
165extern_conformance!(
166    unsafe impl NSCoding for CKSyncEngineStateSerialization {}
167);
168
169extern_conformance!(
170    unsafe impl NSObjectProtocol for CKSyncEngineStateSerialization {}
171);
172
173extern_conformance!(
174    unsafe impl NSSecureCoding for CKSyncEngineStateSerialization {}
175);
176
177impl CKSyncEngineStateSerialization {
178    extern_methods!(
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
189/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginependingrecordzonechangetype?language=objc)
190// NS_ENUM
191#[repr(transparent)]
192#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
193pub struct CKSyncEnginePendingRecordZoneChangeType(pub NSInteger);
194impl CKSyncEnginePendingRecordZoneChangeType {
195    #[doc(alias = "CKSyncEnginePendingRecordZoneChangeTypeSaveRecord")]
196    pub const SaveRecord: Self = Self(0);
197    #[doc(alias = "CKSyncEnginePendingRecordZoneChangeTypeDeleteRecord")]
198    pub const DeleteRecord: Self = Self(1);
199}
200
201unsafe impl Encode for CKSyncEnginePendingRecordZoneChangeType {
202    const ENCODING: Encoding = NSInteger::ENCODING;
203}
204
205unsafe impl RefEncode for CKSyncEnginePendingRecordZoneChangeType {
206    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
207}
208
209extern_class!(
210    /// A change in a record zone that needs to be sent to the server.
211    ///
212    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginependingrecordzonechange?language=objc)
213    #[unsafe(super(NSObject))]
214    #[derive(Debug, PartialEq, Eq, Hash)]
215    pub struct CKSyncEnginePendingRecordZoneChange;
216);
217
218unsafe impl Send for CKSyncEnginePendingRecordZoneChange {}
219
220unsafe impl Sync for CKSyncEnginePendingRecordZoneChange {}
221
222extern_conformance!(
223    unsafe impl NSObjectProtocol for CKSyncEnginePendingRecordZoneChange {}
224);
225
226impl CKSyncEnginePendingRecordZoneChange {
227    extern_methods!(
228        #[cfg(feature = "CKRecordID")]
229        #[unsafe(method(initWithRecordID:type:))]
230        #[unsafe(method_family = init)]
231        pub unsafe fn initWithRecordID_type(
232            this: Allocated<Self>,
233            record_id: &CKRecordID,
234            r#type: CKSyncEnginePendingRecordZoneChangeType,
235        ) -> Retained<Self>;
236
237        #[unsafe(method(init))]
238        #[unsafe(method_family = init)]
239        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
240
241        #[unsafe(method(new))]
242        #[unsafe(method_family = new)]
243        pub unsafe fn new() -> Retained<Self>;
244
245        #[cfg(feature = "CKRecordID")]
246        /// This property is not atomic.
247        ///
248        /// # Safety
249        ///
250        /// This might not be thread-safe.
251        #[unsafe(method(recordID))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn recordID(&self) -> Retained<CKRecordID>;
254
255        /// This property is not atomic.
256        ///
257        /// # Safety
258        ///
259        /// This might not be thread-safe.
260        #[unsafe(method(type))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn r#type(&self) -> CKSyncEnginePendingRecordZoneChangeType;
263    );
264}
265
266/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginependingdatabasechangetype?language=objc)
267// NS_ENUM
268#[repr(transparent)]
269#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
270pub struct CKSyncEnginePendingDatabaseChangeType(pub NSInteger);
271impl CKSyncEnginePendingDatabaseChangeType {
272    #[doc(alias = "CKSyncEnginePendingDatabaseChangeTypeSaveZone")]
273    pub const SaveZone: Self = Self(0);
274    #[doc(alias = "CKSyncEnginePendingDatabaseChangeTypeDeleteZone")]
275    pub const DeleteZone: Self = Self(1);
276}
277
278unsafe impl Encode for CKSyncEnginePendingDatabaseChangeType {
279    const ENCODING: Encoding = NSInteger::ENCODING;
280}
281
282unsafe impl RefEncode for CKSyncEnginePendingDatabaseChangeType {
283    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
284}
285
286extern_class!(
287    /// A change in a database that needs to be sent to the server.
288    ///
289    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginependingdatabasechange?language=objc)
290    #[unsafe(super(NSObject))]
291    #[derive(Debug, PartialEq, Eq, Hash)]
292    pub struct CKSyncEnginePendingDatabaseChange;
293);
294
295unsafe impl Send for CKSyncEnginePendingDatabaseChange {}
296
297unsafe impl Sync for CKSyncEnginePendingDatabaseChange {}
298
299extern_conformance!(
300    unsafe impl NSObjectProtocol for CKSyncEnginePendingDatabaseChange {}
301);
302
303impl CKSyncEnginePendingDatabaseChange {
304    extern_methods!(
305        #[unsafe(method(init))]
306        #[unsafe(method_family = init)]
307        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
308
309        #[unsafe(method(new))]
310        #[unsafe(method_family = new)]
311        pub unsafe fn new() -> Retained<Self>;
312
313        #[cfg(feature = "CKRecordZoneID")]
314        /// This property is not atomic.
315        ///
316        /// # Safety
317        ///
318        /// This might not be thread-safe.
319        #[unsafe(method(zoneID))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn zoneID(&self) -> Retained<CKRecordZoneID>;
322
323        /// This property is not atomic.
324        ///
325        /// # Safety
326        ///
327        /// This might not be thread-safe.
328        #[unsafe(method(type))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn r#type(&self) -> CKSyncEnginePendingDatabaseChangeType;
331    );
332}
333
334extern_class!(
335    /// A zone save that needs to be sent to the server.
336    ///
337    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginependingzonesave?language=objc)
338    #[unsafe(super(CKSyncEnginePendingDatabaseChange, NSObject))]
339    #[derive(Debug, PartialEq, Eq, Hash)]
340    pub struct CKSyncEnginePendingZoneSave;
341);
342
343unsafe impl Send for CKSyncEnginePendingZoneSave {}
344
345unsafe impl Sync for CKSyncEnginePendingZoneSave {}
346
347extern_conformance!(
348    unsafe impl NSObjectProtocol for CKSyncEnginePendingZoneSave {}
349);
350
351impl CKSyncEnginePendingZoneSave {
352    extern_methods!(
353        #[cfg(feature = "CKRecordZone")]
354        #[unsafe(method(initWithZone:))]
355        #[unsafe(method_family = init)]
356        pub unsafe fn initWithZone(this: Allocated<Self>, zone: &CKRecordZone) -> Retained<Self>;
357
358        #[cfg(feature = "CKRecordZone")]
359        /// This property is not atomic.
360        ///
361        /// # Safety
362        ///
363        /// This might not be thread-safe.
364        #[unsafe(method(zone))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn zone(&self) -> Retained<CKRecordZone>;
367    );
368}
369
370/// Methods declared on superclass `CKSyncEnginePendingDatabaseChange`.
371impl CKSyncEnginePendingZoneSave {
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 zone delete that needs to be sent to the server.
385    ///
386    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginependingzonedelete?language=objc)
387    #[unsafe(super(CKSyncEnginePendingDatabaseChange, NSObject))]
388    #[derive(Debug, PartialEq, Eq, Hash)]
389    pub struct CKSyncEnginePendingZoneDelete;
390);
391
392unsafe impl Send for CKSyncEnginePendingZoneDelete {}
393
394unsafe impl Sync for CKSyncEnginePendingZoneDelete {}
395
396extern_conformance!(
397    unsafe impl NSObjectProtocol for CKSyncEnginePendingZoneDelete {}
398);
399
400impl CKSyncEnginePendingZoneDelete {
401    extern_methods!(
402        #[cfg(feature = "CKRecordZoneID")]
403        #[unsafe(method(initWithZoneID:))]
404        #[unsafe(method_family = init)]
405        pub unsafe fn initWithZoneID(
406            this: Allocated<Self>,
407            zone_id: &CKRecordZoneID,
408        ) -> Retained<Self>;
409    );
410}
411
412/// Methods declared on superclass `CKSyncEnginePendingDatabaseChange`.
413impl CKSyncEnginePendingZoneDelete {
414    extern_methods!(
415        #[unsafe(method(init))]
416        #[unsafe(method_family = init)]
417        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
418
419        #[unsafe(method(new))]
420        #[unsafe(method_family = new)]
421        pub unsafe fn new() -> Retained<Self>;
422    );
423}