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 ``CKSyncEngine/Event/StateUpdate``.
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 ///
79 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
80 #[unsafe(method(setStateSerialization:))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn setStateSerialization(
83 &self,
84 state_serialization: Option<&CKSyncEngineStateSerialization>,
85 );
86
87 #[cfg(feature = "CKSyncEngine")]
88 /// Your implementation of `CKSyncEngineDelegate`.
89 #[unsafe(method(delegate))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn delegate(&self)
92 -> Option<Retained<ProtocolObject<dyn CKSyncEngineDelegate>>>;
93
94 #[cfg(feature = "CKSyncEngine")]
95 /// Setter for [`delegate`][Self::delegate].
96 ///
97 /// This is a [weak property][objc2::topics::weak_property].
98 #[unsafe(method(setDelegate:))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn setDelegate(
101 &self,
102 delegate: Option<&ProtocolObject<dyn CKSyncEngineDelegate>>,
103 );
104
105 /// Whether or not the sync engine should automatically sync on your behalf.
106 ///
107 /// If true, then the sync engine will automatically sync using the system scheduler. This is the default value.
108 /// When you add pending changes to the state, the sync engine will automatically schedule a sync task to send changes.
109 /// When it receives a notification about new changes on the server, it will automatically schedule a sync task to fetch changes.
110 /// It will also automatically re-schedule sync tasks for retryable errors such as network failures or server throttles.
111 ///
112 /// If ``CKSyncEngineConfiguration/automaticallySync`` is off, then the sync engine will not perform any operations unless you tell it to do so via ``CKSyncEngine/fetchChanges(_:)`` or ``CKSyncEngine/sendChanges(_:)``.
113 ///
114 /// Most applications likely want to enable automatic syncing during normal use.
115 /// However, you might want to disable it if you have specific requirements for when you want to sync.
116 /// For example, if you want to sync only once per day, you can turn off automatic sync and manually call ``CKSyncEngine/fetchChanges(_:)`` and ``CKSyncEngine/sendChanges(_:)`` once per day.
117 ///
118 /// You might also disable automatic sync when writing automated tests for your integration with `CKSyncEngine`.
119 /// This way, you can have fine grained control over exactly when the sync engine fetches or sends changes.
120 /// This allows you to simulate edge cases and deterministically test your logic around scenarios like conflict resolution and error handling.
121 #[unsafe(method(automaticallySync))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn automaticallySync(&self) -> bool;
124
125 /// Setter for [`automaticallySync`][Self::automaticallySync].
126 #[unsafe(method(setAutomaticallySync:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn setAutomaticallySync(&self, automatically_sync: bool);
129
130 #[cfg(feature = "CKSubscription")]
131 /// An optional override for the sync engine's default database subscription ID.
132 /// Use this for backward compatibility with a previous CloudKit sync implementation.
133 ///
134 /// By default, `CKSyncEngine` will create its own ``CKDatabaseSubscription`` with its own subscription ID.
135 /// If you're migrating to `CKSyncEngine` from a custom CloudKit sync implementation, you can specify your previous subscription ID here.
136 /// This allows your `CKSyncEngine` integration to be backward compatible with previous versions of your app.
137 ///
138 /// >Note: `CKSyncEngine` will automatically attempt to discover any previous database subscriptions,
139 /// but you can be more explicit by giving the subscription ID through this configuration option.
140 #[unsafe(method(subscriptionID))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn subscriptionID(&self) -> Option<Retained<CKSubscriptionID>>;
143
144 #[cfg(feature = "CKSubscription")]
145 /// Setter for [`subscriptionID`][Self::subscriptionID].
146 ///
147 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
148 #[unsafe(method(setSubscriptionID:))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn setSubscriptionID(&self, subscription_id: Option<&CKSubscriptionID>);
151 );
152}