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