objc2_cloud_kit/generated/CKSyncEngineConfiguration.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::*;
6
7use crate::*;
8
9extern_class!(
10 /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksyncengineconfiguration?language=objc)
11 #[unsafe(super(NSObject))]
12 #[derive(Debug, PartialEq, Eq, Hash)]
13 pub struct CKSyncEngineConfiguration;
14);
15
16unsafe impl Send for CKSyncEngineConfiguration {}
17
18unsafe impl Sync for CKSyncEngineConfiguration {}
19
20extern_conformance!(
21 unsafe impl NSObjectProtocol for CKSyncEngineConfiguration {}
22);
23
24impl CKSyncEngineConfiguration {
25 extern_methods!(
26 #[cfg(all(
27 feature = "CKDatabase",
28 feature = "CKSyncEngine",
29 feature = "CKSyncEngineState"
30 ))]
31 #[unsafe(method(initWithDatabase:stateSerialization:delegate:))]
32 #[unsafe(method_family = init)]
33 pub unsafe fn initWithDatabase_stateSerialization_delegate(
34 this: Allocated<Self>,
35 database: &CKDatabase,
36 state_serialization: Option<&CKSyncEngineStateSerialization>,
37 delegate: &ProtocolObject<dyn CKSyncEngineDelegate>,
38 ) -> Retained<Self>;
39
40 #[unsafe(method(init))]
41 #[unsafe(method_family = init)]
42 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
43
44 #[unsafe(method(new))]
45 #[unsafe(method_family = new)]
46 pub unsafe fn new() -> Retained<Self>;
47
48 #[cfg(feature = "CKDatabase")]
49 /// The database for this sync engine to sync with.
50 ///
51 /// You can have multiple instances of `CKSyncEngine` in the same process, each targeting a different database.
52 /// For example, you might have one for your private database and one for your shared database.
53 ///
54 /// It's also technically possible to have multiple instances of `CKSyncEngine` for the same `CKDatabase`.
55 /// This isn't recommended for production code, but it can be helpful for testing your `CKSyncEngine` integration.
56 /// For example, you might make multiple `CKSyncEngine` instances to simulate multiple devices syncing back and forth.
57 #[unsafe(method(database))]
58 #[unsafe(method_family = none)]
59 pub unsafe fn database(&self) -> Retained<CKDatabase>;
60
61 #[cfg(feature = "CKDatabase")]
62 /// Setter for [`database`][Self::database].
63 #[unsafe(method(setDatabase:))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn setDatabase(&self, database: &CKDatabase);
66
67 #[cfg(feature = "CKSyncEngineState")]
68 /// The state serialization you last received in a `CKSyncEngineStateUpdateEvent`.
69 ///
70 /// If this is the first time ever initializing your `CKSyncEngine`, you can provide `nil`.
71 #[unsafe(method(stateSerialization))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn stateSerialization(&self)
74 -> Option<Retained<CKSyncEngineStateSerialization>>;
75
76 #[cfg(feature = "CKSyncEngineState")]
77 /// Setter for [`stateSerialization`][Self::stateSerialization].
78 #[unsafe(method(setStateSerialization:))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn setStateSerialization(
81 &self,
82 state_serialization: Option<&CKSyncEngineStateSerialization>,
83 );
84
85 #[cfg(feature = "CKSyncEngine")]
86 /// Your implementation of `CKSyncEngineDelegate`.
87 #[unsafe(method(delegate))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn delegate(&self)
90 -> Option<Retained<ProtocolObject<dyn CKSyncEngineDelegate>>>;
91
92 #[cfg(feature = "CKSyncEngine")]
93 /// This is a [weak property][objc2::topics::weak_property].
94 /// Setter for [`delegate`][Self::delegate].
95 #[unsafe(method(setDelegate:))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn setDelegate(
98 &self,
99 delegate: Option<&ProtocolObject<dyn CKSyncEngineDelegate>>,
100 );
101
102 /// Whether or not the sync engine should automatically sync on your behalf.
103 ///
104 /// If true, then the sync engine will automatically sync using the system scheduler. This is the default value.
105 /// When you add pending changes to the state, the sync engine will automatically schedule a sync task to send changes.
106 /// When it receives a notification about new changes on the server, it will automatically schedule a sync task to fetch changes.
107 /// It will also automatically re-schedule sync tasks for retryable errors such as network failures or server throttles.
108 ///
109 /// If `automaticallySync` is off, then the sync engine will not perform any operations unless you tell it to do so via `fetchChanges` or `sendChanges`.
110 ///
111 /// Most applications likely want to enable automatic syncing during normal use.
112 /// However, you might want to disable it if you have specific requirements for when you want to sync.
113 /// For example, if you want to sync only once per day, you can turn off automatic sync and manually call `fetchChanges` and `sendChanges` once per day.
114 ///
115 /// You might also disable automatic sync when writing automated tests for your integration with `CKSyncEngine`.
116 /// This way, you can have fine grained control over exactly when the sync engine fetches or sends changes.
117 /// This allows you to simulate edge cases and deterministically test your logic around scenarios like conflict resolution and error handling.
118 #[unsafe(method(automaticallySync))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn automaticallySync(&self) -> bool;
121
122 /// Setter for [`automaticallySync`][Self::automaticallySync].
123 #[unsafe(method(setAutomaticallySync:))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn setAutomaticallySync(&self, automatically_sync: bool);
126
127 #[cfg(feature = "CKSubscription")]
128 /// An optional override for the sync engine's default database subscription ID.
129 /// Use this for backward compatibility with a previous CloudKit sync implementation.
130 ///
131 /// By default, `CKSyncEngine` will create its own `CKDatabaseSubscription` with its own subscription ID.
132 /// If you're migrating to `CKSyncEngine` from a custom CloudKit sync implementation, you can specify your previous subscription ID here.
133 /// This allows your `CKSyncEngine` integration to be backward compatible with previous versions of your app.
134 ///
135 /// >Note: `CKSyncEngine` will automatically attempt to discover any previous database subscriptions,
136 /// but you can be more explicit by giving the subscription ID through this configuration option.
137 #[unsafe(method(subscriptionID))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn subscriptionID(&self) -> Option<Retained<CKSubscriptionID>>;
140
141 #[cfg(feature = "CKSubscription")]
142 /// Setter for [`subscriptionID`][Self::subscriptionID].
143 #[unsafe(method(setSubscriptionID:))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn setSubscriptionID(&self, subscription_id: Option<&CKSubscriptionID>);
146 );
147}