objc2_cloud_kit/generated/
CKDatabase.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
10/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckdatabasescope?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct CKDatabaseScope(pub NSInteger);
15impl CKDatabaseScope {
16    #[doc(alias = "CKDatabaseScopePublic")]
17    pub const Public: Self = Self(1);
18    #[doc(alias = "CKDatabaseScopePrivate")]
19    pub const Private: Self = Self(2);
20    #[doc(alias = "CKDatabaseScopeShared")]
21    pub const Shared: Self = Self(3);
22}
23
24unsafe impl Encode for CKDatabaseScope {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for CKDatabaseScope {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_class!(
33    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckdatabase?language=objc)
34    #[unsafe(super(NSObject))]
35    #[derive(Debug, PartialEq, Eq, Hash)]
36    pub struct CKDatabase;
37);
38
39unsafe impl Send for CKDatabase {}
40
41unsafe impl Sync for CKDatabase {}
42
43extern_conformance!(
44    unsafe impl NSObjectProtocol for CKDatabase {}
45);
46
47impl CKDatabase {
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        #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
58        #[unsafe(method(addOperation:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn addOperation(&self, operation: &CKDatabaseOperation);
61
62        /// This property is not atomic.
63        ///
64        /// # Safety
65        ///
66        /// This might not be thread-safe.
67        #[unsafe(method(databaseScope))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn databaseScope(&self) -> CKDatabaseScope;
70    );
71}
72
73/// ConvenienceMethods.
74///
75/// Convenience APIs
76///
77///
78/// These calls operate on a single item in the default zone and allow for simple operations.
79/// If you'd like to batch your requests, add dependencies between requests, set priorities, or schedule operations on your own queue, take a look at the corresponding
80/// `CKOperation.`This work is treated as having
81/// `NSQualityOfServiceUserInitiated`quality of service.
82impl CKDatabase {
83    extern_methods!(
84        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
85        /// `CKFetchRecordsOperation`and
86        /// `CKModifyRecordsOperation`are the more configurable,
87        /// `CKOperation`-based alternatives to these methods
88        ///
89        /// # Safety
90        ///
91        /// `completion_handler` block must be sendable.
92        #[unsafe(method(fetchRecordWithID:completionHandler:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn fetchRecordWithID_completionHandler(
95            &self,
96            record_id: &CKRecordID,
97            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecord, *mut NSError)>,
98        );
99
100        #[cfg(all(feature = "CKRecord", feature = "block2"))]
101        /// # Safety
102        ///
103        /// `completion_handler` block must be sendable.
104        #[unsafe(method(saveRecord:completionHandler:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn saveRecord_completionHandler(
107            &self,
108            record: &CKRecord,
109            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecord, *mut NSError)>,
110        );
111
112        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
113        /// # Safety
114        ///
115        /// `completion_handler` block must be sendable.
116        #[unsafe(method(deleteRecordWithID:completionHandler:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn deleteRecordWithID_completionHandler(
119            &self,
120            record_id: &CKRecordID,
121            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecordID, *mut NSError)>,
122        );
123
124        #[cfg(all(
125            feature = "CKQuery",
126            feature = "CKRecord",
127            feature = "CKRecordZoneID",
128            feature = "block2"
129        ))]
130        /// `CKQueryOperation`is the more configurable,
131        /// `CKOperation`-based alternative to this method
132        /// Queries can potentially return a large number of records, and the server will return those records in batches. This convenience API will only fetch the first batch of results (equivalent to using
133        /// `CKQueryOperationMaximumResults).`If you would like to fetch all results, use
134        /// `CKQueryOperation`and its
135        /// `CKQueryCursor`instead.
136        /// Queries invoked within a
137        /// `sharedCloudDatabase`must specify a
138        /// `zoneID.`Cross-zone queries are not supported in a
139        /// `sharedCloudDatabase`Queries that do not specify a
140        /// `zoneID`will perform a query across all zones in the database.
141        ///
142        /// # Safety
143        ///
144        /// `completion_handler` block must be sendable.
145        #[unsafe(method(performQuery:inZoneWithID:completionHandler:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn performQuery_inZoneWithID_completionHandler(
148            &self,
149            query: &CKQuery,
150            zone_id: Option<&CKRecordZoneID>,
151            completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<CKRecord>, *mut NSError)>,
152        );
153
154        #[cfg(all(feature = "CKRecordZone", feature = "block2"))]
155        /// `CKFetchRecordZonesOperation`and
156        /// `CKModifyRecordZonesOperation`are the more configurable,
157        /// `CKOperation`-based alternatives to these methods
158        ///
159        /// # Safety
160        ///
161        /// `completion_handler` block must be sendable.
162        #[unsafe(method(fetchAllRecordZonesWithCompletionHandler:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn fetchAllRecordZonesWithCompletionHandler(
165            &self,
166            completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<CKRecordZone>, *mut NSError)>,
167        );
168
169        #[cfg(all(
170            feature = "CKRecordZone",
171            feature = "CKRecordZoneID",
172            feature = "block2"
173        ))]
174        /// # Safety
175        ///
176        /// `completion_handler` block must be sendable.
177        #[unsafe(method(fetchRecordZoneWithID:completionHandler:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn fetchRecordZoneWithID_completionHandler(
180            &self,
181            zone_id: &CKRecordZoneID,
182            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecordZone, *mut NSError)>,
183        );
184
185        #[cfg(all(feature = "CKRecordZone", feature = "block2"))]
186        /// # Safety
187        ///
188        /// `completion_handler` block must be sendable.
189        #[unsafe(method(saveRecordZone:completionHandler:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn saveRecordZone_completionHandler(
192            &self,
193            zone: &CKRecordZone,
194            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecordZone, *mut NSError)>,
195        );
196
197        #[cfg(all(feature = "CKRecordZoneID", feature = "block2"))]
198        /// # Safety
199        ///
200        /// `completion_handler` block must be sendable.
201        #[unsafe(method(deleteRecordZoneWithID:completionHandler:))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn deleteRecordZoneWithID_completionHandler(
204            &self,
205            zone_id: &CKRecordZoneID,
206            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecordZoneID, *mut NSError)>,
207        );
208
209        #[cfg(all(feature = "CKSubscription", feature = "block2"))]
210        /// `CKFetchSubscriptionsOperation`and
211        /// `CKModifySubscriptionsOperation`are the more configurable,
212        /// `CKOperation`-based alternative to these methods
213        ///
214        /// # Safety
215        ///
216        /// `completion_handler` block must be sendable.
217        #[unsafe(method(fetchSubscriptionWithID:completionHandler:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn fetchSubscriptionWithID_completionHandler(
220            &self,
221            subscription_id: &CKSubscriptionID,
222            completion_handler: &block2::DynBlock<dyn Fn(*mut CKSubscription, *mut NSError)>,
223        );
224
225        #[cfg(all(feature = "CKSubscription", feature = "block2"))]
226        /// # Safety
227        ///
228        /// `completion_handler` block must be sendable.
229        #[unsafe(method(fetchAllSubscriptionsWithCompletionHandler:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn fetchAllSubscriptionsWithCompletionHandler(
232            &self,
233            completion_handler: &block2::DynBlock<
234                dyn Fn(*mut NSArray<CKSubscription>, *mut NSError),
235            >,
236        );
237
238        #[cfg(all(feature = "CKSubscription", feature = "block2"))]
239        /// # Safety
240        ///
241        /// `completion_handler` block must be sendable.
242        #[unsafe(method(saveSubscription:completionHandler:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn saveSubscription_completionHandler(
245            &self,
246            subscription: &CKSubscription,
247            completion_handler: &block2::DynBlock<dyn Fn(*mut CKSubscription, *mut NSError)>,
248        );
249
250        #[cfg(all(feature = "CKSubscription", feature = "block2"))]
251        /// # Safety
252        ///
253        /// `completion_handler` block must be sendable.
254        #[unsafe(method(deleteSubscriptionWithID:completionHandler:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn deleteSubscriptionWithID_completionHandler(
257            &self,
258            subscription_id: &CKSubscriptionID,
259            completion_handler: &block2::DynBlock<dyn Fn(*mut CKSubscriptionID, *mut NSError)>,
260        );
261    );
262}