1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern "C" {
    pub static CKCurrentUserDefaultName: &'static NSString;
}

extern "C" {
    pub static CKOwnerDefaultName: &'static NSString;
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CKContainer;

    unsafe impl ClassType for CKContainer {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl Send for CKContainer {}

unsafe impl Sync for CKContainer {}

unsafe impl NSObjectProtocol for CKContainer {}

extern_methods!(
    unsafe impl CKContainer {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;

        #[method_id(@__retain_semantics Other defaultContainer)]
        pub unsafe fn defaultContainer() -> Retained<CKContainer>;

        #[method_id(@__retain_semantics Other containerWithIdentifier:)]
        pub unsafe fn containerWithIdentifier(
            container_identifier: &NSString,
        ) -> Retained<CKContainer>;

        #[method_id(@__retain_semantics Other containerIdentifier)]
        pub unsafe fn containerIdentifier(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "CKOperation")]
        #[method(addOperation:)]
        pub unsafe fn addOperation(&self, operation: &CKOperation);
    }
);

extern_methods!(
    /// Database
    unsafe impl CKContainer {
        #[cfg(feature = "CKDatabase")]
        #[method_id(@__retain_semantics Other privateCloudDatabase)]
        pub unsafe fn privateCloudDatabase(&self) -> Retained<CKDatabase>;

        #[cfg(feature = "CKDatabase")]
        #[method_id(@__retain_semantics Other publicCloudDatabase)]
        pub unsafe fn publicCloudDatabase(&self) -> Retained<CKDatabase>;

        #[cfg(feature = "CKDatabase")]
        #[method_id(@__retain_semantics Other sharedCloudDatabase)]
        pub unsafe fn sharedCloudDatabase(&self) -> Retained<CKDatabase>;

        #[cfg(feature = "CKDatabase")]
        #[method_id(@__retain_semantics Other databaseWithDatabaseScope:)]
        pub unsafe fn databaseWithDatabaseScope(
            &self,
            database_scope: CKDatabaseScope,
        ) -> Retained<CKDatabase>;
    }
);

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CKAccountStatus(pub NSInteger);
impl CKAccountStatus {
    #[doc(alias = "CKAccountStatusCouldNotDetermine")]
    pub const CouldNotDetermine: Self = Self(0);
    #[doc(alias = "CKAccountStatusAvailable")]
    pub const Available: Self = Self(1);
    #[doc(alias = "CKAccountStatusRestricted")]
    pub const Restricted: Self = Self(2);
    #[doc(alias = "CKAccountStatusNoAccount")]
    pub const NoAccount: Self = Self(3);
    #[doc(alias = "CKAccountStatusTemporarilyUnavailable")]
    pub const TemporarilyUnavailable: Self = Self(4);
}

unsafe impl Encode for CKAccountStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for CKAccountStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    pub static CKAccountChangedNotification: &'static NSString;
}

extern_methods!(
    /// AccountStatus
    unsafe impl CKContainer {
        #[cfg(feature = "block2")]
        #[method(accountStatusWithCompletionHandler:)]
        pub unsafe fn accountStatusWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(CKAccountStatus, *mut NSError)>,
        );
    }
);

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CKApplicationPermissions(pub NSUInteger);
bitflags::bitflags! {
    impl CKApplicationPermissions: NSUInteger {
#[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        const CKApplicationPermissionUserDiscoverability = 1<<0;
    }
}

unsafe impl Encode for CKApplicationPermissions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for CKApplicationPermissions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CKApplicationPermissionStatus(pub NSInteger);
impl CKApplicationPermissionStatus {
    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
    #[doc(alias = "CKApplicationPermissionStatusInitialState")]
    pub const InitialState: Self = Self(0);
    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
    #[doc(alias = "CKApplicationPermissionStatusCouldNotComplete")]
    pub const CouldNotComplete: Self = Self(1);
    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
    #[doc(alias = "CKApplicationPermissionStatusDenied")]
    pub const Denied: Self = Self(2);
    #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
    #[doc(alias = "CKApplicationPermissionStatusGranted")]
    pub const Granted: Self = Self(3);
}

unsafe impl Encode for CKApplicationPermissionStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for CKApplicationPermissionStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "block2")]
pub type CKApplicationPermissionBlock =
    *mut block2::Block<dyn Fn(CKApplicationPermissionStatus, *mut NSError)>;

extern_methods!(
    /// ApplicationPermission
    unsafe impl CKContainer {
        #[cfg(feature = "block2")]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(statusForApplicationPermission:completionHandler:)]
        pub unsafe fn statusForApplicationPermission_completionHandler(
            &self,
            application_permission: CKApplicationPermissions,
            completion_handler: CKApplicationPermissionBlock,
        );

        #[cfg(feature = "block2")]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(requestApplicationPermission:completionHandler:)]
        pub unsafe fn requestApplicationPermission_completionHandler(
            &self,
            application_permission: CKApplicationPermissions,
            completion_handler: CKApplicationPermissionBlock,
        );
    }
);

extern_methods!(
    /// UserRecords
    unsafe impl CKContainer {
        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
        #[method(fetchUserRecordIDWithCompletionHandler:)]
        pub unsafe fn fetchUserRecordIDWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(*mut CKRecordID, *mut NSError)>,
        );

        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(discoverAllIdentitiesWithCompletionHandler:)]
        pub unsafe fn discoverAllIdentitiesWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(*mut NSArray<CKUserIdentity>, *mut NSError)>,
        );

        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(discoverUserIdentityWithEmailAddress:completionHandler:)]
        pub unsafe fn discoverUserIdentityWithEmailAddress_completionHandler(
            &self,
            email: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
        );

        #[cfg(all(feature = "CKUserIdentity", feature = "block2"))]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(discoverUserIdentityWithPhoneNumber:completionHandler:)]
        pub unsafe fn discoverUserIdentityWithPhoneNumber_completionHandler(
            &self,
            phone_number: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
        );

        #[cfg(all(feature = "CKRecordID", feature = "CKUserIdentity", feature = "block2"))]
        #[deprecated = "No longer supported. Please see Sharing CloudKit Data with Other iCloud Users."]
        #[method(discoverUserIdentityWithUserRecordID:completionHandler:)]
        pub unsafe fn discoverUserIdentityWithUserRecordID_completionHandler(
            &self,
            user_record_id: &CKRecordID,
            completion_handler: &block2::Block<dyn Fn(*mut CKUserIdentity, *mut NSError)>,
        );
    }
);

extern_methods!(
    /// Sharing
    unsafe impl CKContainer {
        #[cfg(all(feature = "CKShareParticipant", feature = "block2"))]
        #[method(fetchShareParticipantWithEmailAddress:completionHandler:)]
        pub unsafe fn fetchShareParticipantWithEmailAddress_completionHandler(
            &self,
            email_address: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
        );

        #[cfg(all(feature = "CKShareParticipant", feature = "block2"))]
        #[method(fetchShareParticipantWithPhoneNumber:completionHandler:)]
        pub unsafe fn fetchShareParticipantWithPhoneNumber_completionHandler(
            &self,
            phone_number: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
        );

        #[cfg(all(
            feature = "CKRecordID",
            feature = "CKShareParticipant",
            feature = "block2"
        ))]
        #[method(fetchShareParticipantWithUserRecordID:completionHandler:)]
        pub unsafe fn fetchShareParticipantWithUserRecordID_completionHandler(
            &self,
            user_record_id: &CKRecordID,
            completion_handler: &block2::Block<dyn Fn(*mut CKShareParticipant, *mut NSError)>,
        );

        #[cfg(all(feature = "CKShareMetadata", feature = "block2"))]
        #[method(fetchShareMetadataWithURL:completionHandler:)]
        pub unsafe fn fetchShareMetadataWithURL_completionHandler(
            &self,
            url: &NSURL,
            completion_handler: &block2::Block<dyn Fn(*mut CKShareMetadata, *mut NSError)>,
        );

        #[cfg(all(
            feature = "CKRecord",
            feature = "CKShare",
            feature = "CKShareMetadata",
            feature = "block2"
        ))]
        #[method(acceptShareMetadata:completionHandler:)]
        pub unsafe fn acceptShareMetadata_completionHandler(
            &self,
            metadata: &CKShareMetadata,
            completion_handler: &block2::Block<dyn Fn(*mut CKShare, *mut NSError)>,
        );
    }
);

extern_methods!(
    /// CKLongLivedOperations
    unsafe impl CKContainer {
        #[cfg(all(feature = "CKOperation", feature = "block2"))]
        #[method(fetchAllLongLivedOperationIDsWithCompletionHandler:)]
        pub unsafe fn fetchAllLongLivedOperationIDsWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(*mut NSArray<CKOperationID>, *mut NSError)>,
        );

        #[cfg(all(feature = "CKOperation", feature = "block2"))]
        #[method(fetchLongLivedOperationWithID:completionHandler:)]
        pub unsafe fn fetchLongLivedOperationWithID_completionHandler(
            &self,
            operation_id: &CKOperationID,
            completion_handler: &block2::Block<dyn Fn(*mut CKOperation, *mut NSError)>,
        );
    }
);