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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordtypeshare?language=objc)
#[cfg(feature = "CKRecord")]
pub static CKRecordTypeShare: &'static CKRecordType;
}
extern "C" {
/// A zone-wide CKShare always uses the record name
/// `CKRecordNameZoneWideShare.`You can use this to fetch the
/// `CKShare`record for the zone with a
/// `CKFetchRecordsOperation.`
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordnamezonewideshare?language=objc)
pub static CKRecordNameZoneWideShare: &'static NSString;
}
extern "C" {
/// Value is a string. Example for a recipe sharing app: "Pot Roast"
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksharetitlekey?language=objc)
#[cfg(feature = "CKRecord")]
pub static CKShareTitleKey: &'static CKRecordFieldKey;
}
extern "C" {
/// Value is a data blob suitable to pass into
///
/// ```text
/// -[NSImage imageWithData:] or -[UIImage imageWithData:]
/// ```
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksharethumbnailimagedatakey?language=objc)
#[cfg(feature = "CKRecord")]
pub static CKShareThumbnailImageDataKey: &'static CKRecordFieldKey;
}
extern "C" {
/// Value is a string representing a UTI. Example for a recipe sharing app: "com.mycompany.recipe"
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksharetypekey?language=objc)
#[cfg(feature = "CKRecord")]
pub static CKShareTypeKey: &'static CKRecordFieldKey;
}
extern_class!(
/// Like CKRecords, CKShares can store arbitrary key-value pairs. They are modified and fetched in the same manner.
/// A share, its root record, and its root record's children records will only appear in a participant's CKFetchRecordChangesOperation's results after the share has been accepted by that participant.
/// Clients have access to the share (and optionally the root record) before accepting a share, via the CKShareMetadata object. Note that in order to access a root record before accepting a share, you must run a CKFetchShareMetadataOperation requesting the root record.
/// A CKShare will appear in a CKFetchRecordChangesOperation's results set whenever the participant list is updated. For that reason, you shouldn't place heavy key-value pairs in it.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckshare?language=objc)
#[unsafe(super(CKRecord, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "CKRecord")]
pub struct CKShare;
);
#[cfg(feature = "CKRecord")]
extern_conformance!(
unsafe impl NSCoding for CKShare {}
);
#[cfg(feature = "CKRecord")]
extern_conformance!(
unsafe impl NSCopying for CKShare {}
);
#[cfg(feature = "CKRecord")]
unsafe impl CopyingHelper for CKShare {
type Result = Self;
}
#[cfg(feature = "CKRecord")]
extern_conformance!(
unsafe impl NSObjectProtocol for CKShare {}
);
#[cfg(feature = "CKRecord")]
extern_conformance!(
unsafe impl NSSecureCoding for CKShare {}
);
#[cfg(feature = "CKRecord")]
impl CKShare {
extern_methods!(
/// When saving a newly created CKShare, you must save the share and its rootRecord in the same CKModifyRecordsOperation batch.
#[unsafe(method(initWithRootRecord:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithRootRecord(
this: Allocated<Self>,
root_record: &CKRecord,
) -> Retained<Self>;
#[cfg(feature = "CKRecordID")]
#[unsafe(method(initWithRootRecord:shareID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithRootRecord_shareID(
this: Allocated<Self>,
root_record: &CKRecord,
share_id: &CKRecordID,
) -> Retained<Self>;
#[cfg(feature = "CKRecordZoneID")]
/// Creates a zone-wide
/// `CKShare.`A zone-wide
/// `CKShare`can only exist in a zone with sharing capability
/// `CKRecordZoneCapabilityZoneWideSharing.`Only one such share can exist in a zone at a time.
///
/// All records in this zone will appear in a participant's
/// `CKFetchRecordZoneChangesOperation`results in the shared database after the
/// share has been accepted by the participant.
///
/// Since these shares do not have an associated root record,
/// `shouldFetchRootRecord`and
/// `rootRecordDesiredKeys`are always ignored when
/// running a
/// `CKFetchShareMetadataOperation`on a zone-wide share URL. Additionally,
/// `rootRecordID`on the resulting
/// `CKShareMetadata`is
/// always absent.
#[unsafe(method(initWithRecordZoneID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithRecordZoneID(
this: Allocated<Self>,
record_zone_id: &CKRecordZoneID,
) -> Retained<Self>;
/// # Safety
///
/// `a_decoder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(this: Allocated<Self>, a_decoder: &NSCoder) -> Retained<Self>;
#[cfg(feature = "CKShareParticipant")]
/// Defines what permission a user has when not explicitly added to the share.
///
///
/// Shares with
/// `publicPermission`more permissive than
/// `CKShareParticipantPermissionNone`can be joined by any user with access to the share's shareURL.
/// By default, public permission is
/// `CKShareParticipantPermissionNone.`Changing the public permission to
/// `CKShareParticipantPermissionReadOnly`or
/// `CKShareParticipantPermissionReadWrite`will result in all pending participants being removed. Already-accepted participants will remain on the share.
/// Changing the public permission to
/// `CKShareParticipantPermissionNone`will result in all participants being removed from the share. You may subsequently choose to call
/// `addParticipant:`before saving the share, those participants will be added to the share.
#[unsafe(method(publicPermission))]
#[unsafe(method_family = none)]
pub unsafe fn publicPermission(&self) -> CKShareParticipantPermission;
#[cfg(feature = "CKShareParticipant")]
/// Setter for [`publicPermission`][Self::publicPermission].
#[unsafe(method(setPublicPermission:))]
#[unsafe(method_family = none)]
pub unsafe fn setPublicPermission(&self, public_permission: CKShareParticipantPermission);
/// A URL that can be used to invite participants to this share.
///
///
/// Only available after share record has been saved to the server. This url is stable, and is tied to the rootRecord. That is, if you share a rootRecord, delete the share, and re-share the same rootRecord via a newly created share, that newly created share's url will be identical to the prior share's url
#[unsafe(method(URL))]
#[unsafe(method_family = none)]
pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "CKShareParticipant")]
/// All participants on the share that the current user has permissions to see.
///
///
/// At the minimum that will include the owner and the current user.
#[unsafe(method(participants))]
#[unsafe(method_family = none)]
pub unsafe fn participants(&self) -> Retained<NSArray<CKShareParticipant>>;
#[cfg(feature = "CKShareParticipant")]
/// Convenience methods for fetching special users from the participant array
#[unsafe(method(owner))]
#[unsafe(method_family = none)]
pub unsafe fn owner(&self) -> Retained<CKShareParticipant>;
#[cfg(feature = "CKShareParticipant")]
#[unsafe(method(currentUserParticipant))]
#[unsafe(method_family = none)]
pub unsafe fn currentUserParticipant(&self) -> Option<Retained<CKShareParticipant>>;
#[cfg(feature = "CKShareParticipant")]
/// If a participant with a matching userIdentity already exists, then that existing participant's properties will be updated; no new participant will be added.
/// A ``CKShareParticipant`` instance that has already been added to one ``CKShare`` cannot be added to another, unless it is removed from the first ``CKShare`` through `removeParticipant`.
/// In order to modify the list of participants, a share must have publicPermission set to
/// `CKShareParticipantPermissionNone.`That is, you cannot mix-and-match private users and public users in the same share.
///
/// See: CKShareParticipantRole
#[unsafe(method(addParticipant:))]
#[unsafe(method_family = none)]
pub unsafe fn addParticipant(&self, participant: &CKShareParticipant);
#[cfg(feature = "CKShareParticipant")]
/// It's not allowed to call `removeParticipant` on a ``CKShare`` with a ``CKShareParticipant`` that has never been added to that share through `addParticipant`.
#[unsafe(method(removeParticipant:))]
#[unsafe(method_family = none)]
pub unsafe fn removeParticipant(&self, participant: &CKShareParticipant);
/// Invitation URLs that can be used by any receiver to claim the associated participantID and join the share.
///
/// Only available after a share record has been saved to the server for participants created via ``CKShareParticipant/oneTimeURLParticipant``.
/// One-time URLs are stable, and tied to the associated participantIDs as long as the participant is part of the share.
/// Typically, a recipient user invited via their handle is provided a ``URL`` directly by the share's owner.
/// However, any user can also use a one-time URL in the same manner to fetch share metadata and accept the share.
/// After share acceptance, the one-time URL becomes functionally equivalent to the regular ``URL``.
///
/// - Parameters:
/// - participantID: The ``CKShareParticipant/participantID`` corresponding to the ``CKShareParticipant/oneTimeURLParticipant`` added to the share.
#[unsafe(method(oneTimeURLForParticipantID:))]
#[unsafe(method_family = none)]
pub unsafe fn oneTimeURLForParticipantID(
&self,
participant_id: &NSString,
) -> Option<Retained<NSURL>>;
/// These superclass-provided initializers are not allowed for CKShare
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[unsafe(method(initWithRecordType:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithRecordType(
this: Allocated<Self>,
record_type: &CKRecordType,
) -> Retained<Self>;
#[cfg(feature = "CKRecordID")]
#[unsafe(method(initWithRecordType:recordID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithRecordType_recordID(
this: Allocated<Self>,
record_type: &CKRecordType,
record_id: &CKRecordID,
) -> Retained<Self>;
#[cfg(feature = "CKRecordZoneID")]
#[unsafe(method(initWithRecordType:zoneID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithRecordType_zoneID(
this: Allocated<Self>,
record_type: &CKRecordType,
zone_id: &CKRecordZoneID,
) -> Retained<Self>;
#[cfg(feature = "CKShareAccessRequester")]
/// A list of all uninvited users who have requested access to this share.
///
/// When share access requests are allowed, uninvited users can request to join the share.
/// All pending access requests appear in this array. Each requester is returned with name components
/// and either an email or phone number.
///
/// Either share owners or administrators can respond to these access requests.
///
/// ### Responding to Access Requests:
///
/// - **Approve Requesters:**
/// - Fetch the participant information by running ``CKFetchShareParticipantsOperation`` with
/// the requester's ``CKShareAccessRequester/participantLookupInfo``.
/// - Add the resulting participant to the share.
///
/// - **Deny Requesters:**
/// - Use ``CloudKit/CKShare/denyRequesters:`` to remove the requester from the requesters list.
///
/// - **Block Requesters:**
/// - Use ``CloudKit/CKShare/blockRequesters:`` to block requesters.
/// - Blocking a requester prevents them from sending future access requests to the share.
#[unsafe(method(requesters))]
#[unsafe(method_family = none)]
pub unsafe fn requesters(&self) -> Retained<NSArray<CKShareAccessRequester>>;
#[cfg(feature = "CKShareBlockedIdentity")]
/// A list of users blocked from requesting access to this share.
///
/// Identities remain in this list until an owner or administrator calls ``CloudKit/CKShare/unblockIdentities:``.
#[unsafe(method(blockedIdentities))]
#[unsafe(method_family = none)]
pub unsafe fn blockedIdentities(&self) -> Retained<NSArray<CKShareBlockedIdentity>>;
/// Indicates whether uninvited users can request access to this share.
///
/// By default, this property is set to `NO`. When set to `YES`, uninvited users can request
/// access to the share if they discover the share URL. When set to `NO`, the server prevents uninvited users
/// from requesting access and does not indicate whether the share exists.
///
/// Only the share owner or an administrator can modify this property. Attempts by other participants
/// to modify this property result in an exception.
#[unsafe(method(allowsAccessRequests))]
#[unsafe(method_family = none)]
pub unsafe fn allowsAccessRequests(&self) -> bool;
/// Setter for [`allowsAccessRequests`][Self::allowsAccessRequests].
#[unsafe(method(setAllowsAccessRequests:))]
#[unsafe(method_family = none)]
pub unsafe fn setAllowsAccessRequests(&self, allows_access_requests: bool);
#[cfg(feature = "CKShareAccessRequester")]
/// Denies access requests from specified users.
///
/// Use this method to deny pending access requests from uninvited users. Denied requesters are removed
/// from the ``CloudKit/CKShare/requesters`` array. To persist the changes, save the share to the server
/// after calling this method.
///
/// After denial, requesters can still submit new access requests unless explicitly blocked using
/// ``CloudKit/CKShare/blockRequesters:``.
///
/// Only the share owner or an administrator can invoke this method. Attempts by other participants
/// result in an exception.
///
/// - Parameter requesters: An array of ``CKShareAccessRequester`` objects to deny.
#[unsafe(method(denyRequesters:))]
#[unsafe(method_family = none)]
pub unsafe fn denyRequesters(&self, requesters: &NSArray<CKShareAccessRequester>);
#[cfg(feature = "CKShareAccessRequester")]
/// Blocks specified users from requesting access to this share.
///
/// Blocking prevents users from submitting future access requests and removes existing participants from the share.
/// Blocked requesters appear in the ``CloudKit/CKShare/blockedIdentities`` array.
///
/// To persist this change, save the share to the server after calling this method.
///
/// Only the share owner or an administrator can invoke this method. Attempts by other participants
/// result in an exception.
///
/// - Parameter requesters: An array of ``CKShareAccessRequester`` objects to block.
#[unsafe(method(blockRequesters:))]
#[unsafe(method_family = none)]
pub unsafe fn blockRequesters(&self, requesters: &NSArray<CKShareAccessRequester>);
#[cfg(feature = "CKShareBlockedIdentity")]
/// Unblocks previously blocked users, allowing them to request access again.
///
/// Use this method to remove specified identities from the ``CloudKit/CKShare/blockedIdentities`` array.
/// Unblocked identities can request access again if access requests are enabled.
///
/// To persist this change, save the share to the server after calling this method.
///
/// Only the share owner or an administrator can invoke this method. Attempts by other participants
/// result in an exception.
///
/// - Parameter blockedIdentities: An array of ``CKShareBlockedIdentity`` objects to unblock.
#[unsafe(method(unblockIdentities:))]
#[unsafe(method_family = none)]
pub unsafe fn unblockIdentities(
&self,
blocked_identities: &NSArray<CKShareBlockedIdentity>,
);
);
}