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