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