objc2_cloud_kit/generated/
CKContainer.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 "C" {
11    /// Stand-in for the current user's ID; most often used in RecordZoneID->ownerName
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckcurrentuserdefaultname?language=objc)
14    pub static CKCurrentUserDefaultName: &'static NSString;
15}
16
17extern "C" {
18    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckownerdefaultname?language=objc)
19    pub static CKOwnerDefaultName: &'static NSString;
20}
21
22extern_class!(
23    /// A CKContainer, and its CKDatabases, are the main entry points into the CloudKit framework.
24    ///
25    ///
26    /// Several methods in CloudKit accept completion handlers to indicate when they're completed.
27    /// All CKOperation subclasses include progress and completion blocks to report significant events in their lifecycles.
28    /// Each of these handlers and blocks is invoked on a non-main serial queue.  The receiver is responsible for handling the message on a different queue or thread if it is required.
29    ///
30    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckcontainer?language=objc)
31    #[unsafe(super(NSObject))]
32    #[derive(Debug, PartialEq, Eq, Hash)]
33    pub struct CKContainer;
34);
35
36unsafe impl Send for CKContainer {}
37
38unsafe impl Sync for CKContainer {}
39
40unsafe impl NSObjectProtocol for CKContainer {}
41
42impl CKContainer {
43    extern_methods!(
44        #[unsafe(method(init))]
45        #[unsafe(method_family = init)]
46        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
47
48        #[unsafe(method(new))]
49        #[unsafe(method_family = new)]
50        pub unsafe fn new() -> Retained<Self>;
51
52        /// Convenience method that uses the calling process' "iCloud.\(application-identifier)" as the container identifier
53        ///
54        ///
55        /// application-identifier is the calling process'
56        /// `application-identifier`entitlement on iOS / tvOS / watchOS.
57        /// application-identifier is the calling process'
58        /// `com.apple.application-identifier`entitlement on macOS.
59        /// On all OSes, if an
60        /// `com.apple.developer.associated-application-identifier`entitlement is present, its value will be preferred over the
61        /// `application-identifier`variants.
62        #[unsafe(method(defaultContainer))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn defaultContainer() -> Retained<CKContainer>;
65
66        /// Obtain a CKContainer for the given containerIdentifier
67        ///
68        ///
69        /// If the application is in production mode (aka,
70        /// `com.apple.developer.icloud-container-environment`is set to Production in your entitlements plist, and you have no override in
71        /// `com.apple.developer.icloud-container-development-container-identifiers),`then the production environment is used.
72        #[unsafe(method(containerWithIdentifier:))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn containerWithIdentifier(
75            container_identifier: &NSString,
76        ) -> Retained<CKContainer>;
77
78        #[unsafe(method(containerIdentifier))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn containerIdentifier(&self) -> Option<Retained<NSString>>;
81
82        #[cfg(feature = "CKOperation")]
83        #[unsafe(method(addOperation:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn addOperation(&self, operation: &CKOperation);
86    );
87}
88
89/// Database.
90/// Database properties:
91/// Records in a public database
92/// - By default are world readable, owner writable.
93/// - Can be locked down by Roles, a process done in the Developer Portal, a web interface.  Roles are not present in the client API.
94/// - Are visible to the application developer via the Developer Portal.
95/// - Do not contribute to the owner's iCloud account storage quota.
96/// Records in a private database
97/// - By default are only owner readable and owner writable.
98/// - Are not visible to the application developer via the Developer Portal.
99/// - Are counted towards the owner's iCloud account storage quota.
100/// Records in a shared database
101/// - Are available to share participants based on the permissions of the enclosing CKShare
102/// - Are not visible to the application developer via the Developer Portal.
103/// - Are counted towards the originating owner's iCloud account storage quota.
104impl CKContainer {
105    extern_methods!(
106        #[cfg(feature = "CKDatabase")]
107        #[unsafe(method(privateCloudDatabase))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn privateCloudDatabase(&self) -> Retained<CKDatabase>;
110
111        #[cfg(feature = "CKDatabase")]
112        #[unsafe(method(publicCloudDatabase))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn publicCloudDatabase(&self) -> Retained<CKDatabase>;
115
116        #[cfg(feature = "CKDatabase")]
117        #[unsafe(method(sharedCloudDatabase))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn sharedCloudDatabase(&self) -> Retained<CKDatabase>;
120
121        #[cfg(feature = "CKDatabase")]
122        /// Convenience methods
123        ///
124        ///
125        /// Returns: a database that's pointer-equal to one of the above properties
126        #[unsafe(method(databaseWithDatabaseScope:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn databaseWithDatabaseScope(
129            &self,
130            database_scope: CKDatabaseScope,
131        ) -> Retained<CKDatabase>;
132    );
133}
134
135/// credentials in Settings app.
136///
137/// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckaccountstatus?language=objc)
138// NS_ENUM
139#[repr(transparent)]
140#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
141pub struct CKAccountStatus(pub NSInteger);
142impl CKAccountStatus {
143    #[doc(alias = "CKAccountStatusCouldNotDetermine")]
144    pub const CouldNotDetermine: Self = Self(0);
145    #[doc(alias = "CKAccountStatusAvailable")]
146    pub const Available: Self = Self(1);
147    #[doc(alias = "CKAccountStatusRestricted")]
148    pub const Restricted: Self = Self(2);
149    #[doc(alias = "CKAccountStatusNoAccount")]
150    pub const NoAccount: Self = Self(3);
151    #[doc(alias = "CKAccountStatusTemporarilyUnavailable")]
152    pub const TemporarilyUnavailable: Self = Self(4);
153}
154
155unsafe impl Encode for CKAccountStatus {
156    const ENCODING: Encoding = NSInteger::ENCODING;
157}
158
159unsafe impl RefEncode for CKAccountStatus {
160    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
161}
162
163extern "C" {
164    /// This local notification is posted when there has been any change to the logged in iCloud account.
165    ///
166    ///
167    /// On receipt, an updated account status should be obtained by calling
168    /// `accountStatusWithCompletionHandler:`
169    ///
170    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckaccountchangednotification?language=objc)
171    pub static CKAccountChangedNotification: &'static NSString;
172}
173
174/// AccountStatus.
175impl CKContainer {
176    extern_methods!(
177        #[cfg(feature = "block2")]
178        #[unsafe(method(accountStatusWithCompletionHandler:))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn accountStatusWithCompletionHandler(
181            &self,
182            completion_handler: &block2::Block<dyn Fn(CKAccountStatus, *mut NSError)>,
183        );
184    );
185}
186
187/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckapplicationpermissions?language=objc)
188// NS_OPTIONS
189#[repr(transparent)]
190#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
191pub struct CKApplicationPermissions(pub NSUInteger);
192bitflags::bitflags! {
193    impl CKApplicationPermissions: NSUInteger {
194/// Allows the user's record in CloudKit to be discoverable via the user's email address
195#[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
196        #[doc(alias = "CKApplicationPermissionUserDiscoverability")]
197        const UserDiscoverability = 1<<0;
198    }
199}
200
201unsafe impl Encode for CKApplicationPermissions {
202    const ENCODING: Encoding = NSUInteger::ENCODING;
203}
204
205unsafe impl RefEncode for CKApplicationPermissions {
206    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
207}
208
209/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckapplicationpermissionstatus?language=objc)
210// NS_ENUM
211#[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
212#[repr(transparent)]
213#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
214pub struct CKApplicationPermissionStatus(pub NSInteger);
215impl CKApplicationPermissionStatus {
216    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
217    #[doc(alias = "CKApplicationPermissionStatusInitialState")]
218    pub const InitialState: Self = Self(0);
219    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
220    #[doc(alias = "CKApplicationPermissionStatusCouldNotComplete")]
221    pub const CouldNotComplete: Self = Self(1);
222    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
223    #[doc(alias = "CKApplicationPermissionStatusDenied")]
224    pub const Denied: Self = Self(2);
225    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
226    #[doc(alias = "CKApplicationPermissionStatusGranted")]
227    pub const Granted: Self = Self(3);
228}
229
230unsafe impl Encode for CKApplicationPermissionStatus {
231    const ENCODING: Encoding = NSInteger::ENCODING;
232}
233
234unsafe impl RefEncode for CKApplicationPermissionStatus {
235    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
236}
237
238/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckapplicationpermissionblock?language=objc)
239#[cfg(feature = "block2")]
240pub type CKApplicationPermissionBlock =
241    *mut block2::Block<dyn Fn(CKApplicationPermissionStatus, *mut NSError)>;
242
243/// ApplicationPermission.
244impl CKContainer {
245    extern_methods!(
246        #[cfg(feature = "block2")]
247        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
248        #[unsafe(method(statusForApplicationPermission:completionHandler:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn statusForApplicationPermission_completionHandler(
251            &self,
252            application_permission: CKApplicationPermissions,
253            completion_handler: CKApplicationPermissionBlock,
254        );
255
256        #[cfg(feature = "block2")]
257        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
258        #[unsafe(method(requestApplicationPermission:completionHandler:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn requestApplicationPermission_completionHandler(
261            &self,
262            application_permission: CKApplicationPermissions,
263            completion_handler: CKApplicationPermissionBlock,
264        );
265    );
266}
267
268/// UserRecords.
269impl CKContainer {
270    extern_methods!(
271        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
272        /// If there is no iCloud account configured, or if access is restricted, a
273        /// `CKErrorNotAuthenticated`error will be returned.
274        ///
275        /// This work is treated as having
276        /// `NSQualityOfServiceUserInitiated`quality of service.
277        #[unsafe(method(fetchUserRecordIDWithCompletionHandler:))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn fetchUserRecordIDWithCompletionHandler(
280            &self,
281            completion_handler: &block2::Block<dyn Fn(*mut CKRecordID, *mut NSError)>,
282        );
283
284        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
285        /// Fetches all user identities that match an entry in the user's contacts database.
286        ///
287        ///
288        /// `CKDiscoverAllUserIdentitiesOperation`is the more configurable,
289        /// `CKOperation`-based alternative to this methods
290        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
291        #[unsafe(method(discoverAllIdentitiesWithCompletionHandler:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn discoverAllIdentitiesWithCompletionHandler(
294            &self,
295            completion_handler: &block2::Block<dyn Fn(*mut NSArray<CKUserIdentity>, *mut NSError)>,
296        );
297
298        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
299        /// Fetches the user identity that corresponds to the given email address.
300        ///
301        ///
302        /// Only users who have opted-in to user discoverability will have their identities returned by this method.  If a user with the inputted email exists in iCloud, but has not opted-in to user discoverability, this method completes with a nil
303        /// `userInfo.``CKDiscoverUserIdentitiesOperation`is the more configurable,
304        /// `CKOperation`-based alternative to this method
305        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
306        #[unsafe(method(discoverUserIdentityWithEmailAddress:completionHandler:))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn discoverUserIdentityWithEmailAddress_completionHandler(
309            &self,
310            email: &NSString,
311            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
312        );
313
314        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
315        /// Fetches the user identity that corresponds to the given phone number.
316        ///
317        ///
318        /// Only users who have opted-in to user discoverability will have their identities returned by this method.  If a user with the inputted phone number exists in iCloud, but has not opted-in to user discoverability, this method completes with a nil
319        /// `userInfo.``CKDiscoverUserIdentitiesOperation`is the more configurable,
320        /// `CKOperation`-based alternative to this method
321        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
322        #[unsafe(method(discoverUserIdentityWithPhoneNumber:completionHandler:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn discoverUserIdentityWithPhoneNumber_completionHandler(
325            &self,
326            phone_number: &NSString,
327            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
328        );
329
330        #[cfg(all(feature = "CKRecordID", feature = "CKUserIdentity", feature = "block2"))]
331        /// Fetches the user identity that corresponds to the given user record id.
332        ///
333        ///
334        /// Only users who have opted-in to user discoverability will have their identities returned by this method.  If a user has not opted-in to user discoverability, this method completes with a nil
335        /// `userInfo.``CKDiscoverUserIdentitiesOperation`is the more configurable,
336        /// `CKOperation`-based alternative to this method
337        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
338        #[unsafe(method(discoverUserIdentityWithUserRecordID:completionHandler:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn discoverUserIdentityWithUserRecordID_completionHandler(
341            &self,
342            user_record_id: &CKRecordID,
343            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
344        );
345    );
346}
347
348/// Sharing.
349impl CKContainer {
350    extern_methods!(
351        #[cfg(all(feature = "CKShareParticipant", feature = "block2"))]
352        /// Fetches share participants matching the provided info.
353        ///
354        ///
355        /// `CKFetchShareParticipantsOperation`is the more configurable,
356        /// `CKOperation`-based alternative to these methods.
357        #[unsafe(method(fetchShareParticipantWithEmailAddress:completionHandler:))]
358        #[unsafe(method_family = none)]
359        pub unsafe fn fetchShareParticipantWithEmailAddress_completionHandler(
360            &self,
361            email_address: &NSString,
362            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
363        );
364
365        #[cfg(all(feature = "CKShareParticipant", feature = "block2"))]
366        #[unsafe(method(fetchShareParticipantWithPhoneNumber:completionHandler:))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn fetchShareParticipantWithPhoneNumber_completionHandler(
369            &self,
370            phone_number: &NSString,
371            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
372        );
373
374        #[cfg(all(
375            feature = "CKRecordID",
376            feature = "CKShareParticipant",
377            feature = "block2"
378        ))]
379        #[unsafe(method(fetchShareParticipantWithUserRecordID:completionHandler:))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn fetchShareParticipantWithUserRecordID_completionHandler(
382            &self,
383            user_record_id: &CKRecordID,
384            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
385        );
386
387        #[cfg(all(feature = "CKShareMetadata", feature = "block2"))]
388        #[unsafe(method(fetchShareMetadataWithURL:completionHandler:))]
389        #[unsafe(method_family = none)]
390        pub unsafe fn fetchShareMetadataWithURL_completionHandler(
391            &self,
392            url: &NSURL,
393            completion_handler: &block2::Block<dyn Fn(*mut CKShareMetadata, *mut NSError)>,
394        );
395
396        #[cfg(all(
397            feature = "CKRecord",
398            feature = "CKShare",
399            feature = "CKShareMetadata",
400            feature = "block2"
401        ))]
402        #[unsafe(method(acceptShareMetadata:completionHandler:))]
403        #[unsafe(method_family = none)]
404        pub unsafe fn acceptShareMetadata_completionHandler(
405            &self,
406            metadata: &CKShareMetadata,
407            completion_handler: &block2::Block<dyn Fn(*mut CKShare, *mut NSError)>,
408        );
409    );
410}
411
412/// CKLongLivedOperations.
413impl CKContainer {
414    extern_methods!(
415        #[cfg(all(feature = "CKOperation", feature = "block2"))]
416        /// Long lived CKOperations returned by this call must be started on an operation queue.
417        /// Remember to set the callback blocks before starting the operation.
418        /// If an operation has already completed against the server, and is subsequently resumed, that operation will replay all of its callbacks from the start of the operation, but the request will not be re-sent to the server.
419        /// If a long lived operation is cancelled or finishes completely it is no longer returned by these calls.
420        #[unsafe(method(fetchAllLongLivedOperationIDsWithCompletionHandler:))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn fetchAllLongLivedOperationIDsWithCompletionHandler(
423            &self,
424            completion_handler: &block2::Block<dyn Fn(*mut NSArray<CKOperationID>, *mut NSError)>,
425        );
426
427        #[cfg(all(feature = "CKOperation", feature = "block2"))]
428        #[unsafe(method(fetchLongLivedOperationWithID:completionHandler:))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn fetchLongLivedOperationWithID_completionHandler(
431            &self,
432            operation_id: &CKOperationID,
433            completion_handler: &block2::Block<dyn Fn(*mut CKOperation, *mut NSError)>,
434        );
435    );
436}