objc2_cloud_kit/generated/CKSyncEngineRecordZoneChangeBatch.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 /// A batch of record zone changes that `CKSyncEngine` will send to the server in a single request.
12 ///
13 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncenginerecordzonechangebatch?language=objc)
14 #[unsafe(super(NSObject))]
15 #[derive(Debug, PartialEq, Eq, Hash)]
16 pub struct CKSyncEngineRecordZoneChangeBatch;
17);
18
19unsafe impl Send for CKSyncEngineRecordZoneChangeBatch {}
20
21unsafe impl Sync for CKSyncEngineRecordZoneChangeBatch {}
22
23extern_conformance!(
24 unsafe impl NSObjectProtocol for CKSyncEngineRecordZoneChangeBatch {}
25);
26
27impl CKSyncEngineRecordZoneChangeBatch {
28 extern_methods!(
29 #[cfg(all(
30 feature = "CKRecord",
31 feature = "CKRecordID",
32 feature = "CKSyncEngineState",
33 feature = "block2"
34 ))]
35 /// Creates a batch of record zone changes according to a list of pending changes.
36 ///
37 /// This will iterate over the pending changes in order and add them to the batch until it reaches the max batch size.
38 ///
39 /// When it sees a pending save, it will ask the record provider for the actual ``CKRecord`` to send to the server.
40 /// If you return `nil` from the record provider, this will skip to the next pending change.
41 ///
42 /// This will return `nil` if there are no pending changes to send.
43 ///
44 /// # Safety
45 ///
46 /// `record_provider` block must be sendable.
47 #[unsafe(method(initWithPendingChanges:recordProvider:))]
48 #[unsafe(method_family = init)]
49 pub unsafe fn initWithPendingChanges_recordProvider(
50 this: Allocated<Self>,
51 pending_changes: &NSArray<CKSyncEnginePendingRecordZoneChange>,
52 record_provider: &block2::DynBlock<dyn Fn(NonNull<CKRecordID>) -> *mut CKRecord + '_>,
53 ) -> Option<Retained<Self>>;
54
55 #[cfg(all(feature = "CKRecord", feature = "CKRecordID"))]
56 /// Creates a batch of record zone changes to send to the server with a specific set of changes.
57 ///
58 /// If you'd like to construct your own custom batches of changes to send to the server, you can do so with this initializer.
59 ///
60 /// ## Batch size limitations
61 ///
62 /// When creating your own batches, you need to consider batch size limitations.
63 /// There is a maximum count and size of records that can be sent to the server in a single batch.
64 /// If you supply too many changes, or if the total size of the records is too large, then you might get a ``CKError/limitExceeded``.
65 ///
66 /// > Tip: These batch size limitations are handled automatically by the ``initWithPendingChanges:recordProvider:`` initializer.
67 #[unsafe(method(initWithRecordsToSave:recordIDsToDelete:atomicByZone:))]
68 #[unsafe(method_family = init)]
69 pub unsafe fn initWithRecordsToSave_recordIDsToDelete_atomicByZone(
70 this: Allocated<Self>,
71 records_to_save: Option<&NSArray<CKRecord>>,
72 record_i_ds_to_delete: Option<&NSArray<CKRecordID>>,
73 atomic_by_zone: bool,
74 ) -> Retained<Self>;
75
76 #[unsafe(method(init))]
77 #[unsafe(method_family = init)]
78 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
79
80 #[unsafe(method(new))]
81 #[unsafe(method_family = new)]
82 pub unsafe fn new() -> Retained<Self>;
83
84 #[cfg(feature = "CKRecord")]
85 /// The records to save to the server.
86 #[unsafe(method(recordsToSave))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn recordsToSave(&self) -> Retained<NSArray<CKRecord>>;
89
90 #[cfg(feature = "CKRecordID")]
91 /// The IDs of the records to delete from the server.
92 #[unsafe(method(recordIDsToDelete))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn recordIDsToDelete(&self) -> Retained<NSArray<CKRecordID>>;
95
96 /// If set to true, the sync engine will modify these records atomically by zone.
97 ///
98 /// If this is true, and if any record change fails, then any other changes from that zone in this batch will also fail with ``CKError/batchRequestFailed``.
99 ///
100 /// Records that exist in different zones will not be modified together atomically.
101 #[unsafe(method(atomicByZone))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn atomicByZone(&self) -> bool;
104
105 /// Setter for [`atomicByZone`][Self::atomicByZone].
106 #[unsafe(method(setAtomicByZone:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn setAtomicByZone(&self, atomic_by_zone: bool);
109 );
110}