objc2_cloud_kit/generated/
CKShare.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    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordtypeshare?language=objc)
12    #[cfg(feature = "CKRecord")]
13    pub static CKRecordTypeShare: &'static CKRecordType;
14}
15
16extern "C" {
17    /// A zone-wide CKShare always uses the record name
18    /// `CKRecordNameZoneWideShare.`You can use this to fetch the
19    /// `CKShare`record for the zone with a
20    /// `CKFetchRecordsOperation.`
21    ///
22    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordnamezonewideshare?language=objc)
23    pub static CKRecordNameZoneWideShare: &'static NSString;
24}
25
26extern "C" {
27    /// Value is a string.  Example for a recipe sharing app: "Pot Roast"
28    ///
29    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksharetitlekey?language=objc)
30    #[cfg(feature = "CKRecord")]
31    pub static CKShareTitleKey: &'static CKRecordFieldKey;
32}
33
34extern "C" {
35    /// Value is a data blob suitable to pass into
36    ///
37    /// ```text
38    ///  -[NSImage imageWithData:] or -[UIImage imageWithData:]
39    /// ```
40    ///
41    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksharethumbnailimagedatakey?language=objc)
42    #[cfg(feature = "CKRecord")]
43    pub static CKShareThumbnailImageDataKey: &'static CKRecordFieldKey;
44}
45
46extern "C" {
47    /// Value is a string representing a UTI.  Example for a recipe sharing app: "com.mycompany.recipe"
48    ///
49    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cksharetypekey?language=objc)
50    #[cfg(feature = "CKRecord")]
51    pub static CKShareTypeKey: &'static CKRecordFieldKey;
52}
53
54extern_class!(
55    /// Like CKRecords, CKShares can store arbitrary key-value pairs.  They are modified and fetched in the same manner.
56    /// 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.
57    /// 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.
58    /// 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.
59    ///
60    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckshare?language=objc)
61    #[unsafe(super(CKRecord, NSObject))]
62    #[derive(Debug, PartialEq, Eq, Hash)]
63    #[cfg(feature = "CKRecord")]
64    pub struct CKShare;
65);
66
67#[cfg(feature = "CKRecord")]
68extern_conformance!(
69    unsafe impl NSCoding for CKShare {}
70);
71
72#[cfg(feature = "CKRecord")]
73extern_conformance!(
74    unsafe impl NSCopying for CKShare {}
75);
76
77#[cfg(feature = "CKRecord")]
78unsafe impl CopyingHelper for CKShare {
79    type Result = Self;
80}
81
82#[cfg(feature = "CKRecord")]
83extern_conformance!(
84    unsafe impl NSObjectProtocol for CKShare {}
85);
86
87#[cfg(feature = "CKRecord")]
88extern_conformance!(
89    unsafe impl NSSecureCoding for CKShare {}
90);
91
92#[cfg(feature = "CKRecord")]
93impl CKShare {
94    extern_methods!(
95        /// When saving a newly created CKShare, you must save the share and its rootRecord in the same CKModifyRecordsOperation batch.
96        #[unsafe(method(initWithRootRecord:))]
97        #[unsafe(method_family = init)]
98        pub unsafe fn initWithRootRecord(
99            this: Allocated<Self>,
100            root_record: &CKRecord,
101        ) -> Retained<Self>;
102
103        #[cfg(feature = "CKRecordID")]
104        #[unsafe(method(initWithRootRecord:shareID:))]
105        #[unsafe(method_family = init)]
106        pub unsafe fn initWithRootRecord_shareID(
107            this: Allocated<Self>,
108            root_record: &CKRecord,
109            share_id: &CKRecordID,
110        ) -> Retained<Self>;
111
112        #[cfg(feature = "CKRecordZoneID")]
113        /// Creates a zone-wide
114        /// `CKShare.`A zone-wide
115        /// `CKShare`can only exist in a zone with sharing capability
116        /// `CKRecordZoneCapabilityZoneWideSharing.`Only one such share can exist in a zone at a time.
117        ///
118        /// All records in this zone will appear in a participant's
119        /// `CKFetchRecordZoneChangesOperation`results in the shared database after the
120        /// share has been accepted by the participant.
121        ///
122        /// Since these shares do not have an associated root record,
123        /// `shouldFetchRootRecord`and
124        /// `rootRecordDesiredKeys`are always ignored when
125        /// running a
126        /// `CKFetchShareMetadataOperation`on a zone-wide share URL. Additionally,
127        /// `rootRecordID`on the resulting
128        /// `CKShareMetadata`is
129        /// always absent.
130        #[unsafe(method(initWithRecordZoneID:))]
131        #[unsafe(method_family = init)]
132        pub unsafe fn initWithRecordZoneID(
133            this: Allocated<Self>,
134            record_zone_id: &CKRecordZoneID,
135        ) -> Retained<Self>;
136
137        /// # Safety
138        ///
139        /// `a_decoder` possibly has further requirements.
140        #[unsafe(method(initWithCoder:))]
141        #[unsafe(method_family = init)]
142        pub unsafe fn initWithCoder(this: Allocated<Self>, a_decoder: &NSCoder) -> Retained<Self>;
143
144        #[cfg(feature = "CKShareParticipant")]
145        /// Defines what permission a user has when not explicitly added to the share.
146        ///
147        ///
148        /// Shares with
149        /// `publicPermission`more permissive than
150        /// `CKShareParticipantPermissionNone`can be joined by any user with access to the share's shareURL.
151        /// By default, public permission is
152        /// `CKShareParticipantPermissionNone.`Changing the public permission to
153        /// `CKShareParticipantPermissionReadOnly`or
154        /// `CKShareParticipantPermissionReadWrite`will result in all pending participants being removed.  Already-accepted participants will remain on the share.
155        /// Changing the public permission to
156        /// `CKShareParticipantPermissionNone`will result in all participants being removed from the share.  You may subsequently choose to call
157        /// `addParticipant:`before saving the share, those participants will be added to the share.
158        #[unsafe(method(publicPermission))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn publicPermission(&self) -> CKShareParticipantPermission;
161
162        #[cfg(feature = "CKShareParticipant")]
163        /// Setter for [`publicPermission`][Self::publicPermission].
164        #[unsafe(method(setPublicPermission:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setPublicPermission(&self, public_permission: CKShareParticipantPermission);
167
168        /// A URL that can be used to invite participants to this share.
169        ///
170        ///
171        /// 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
172        #[unsafe(method(URL))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
175
176        #[cfg(feature = "CKShareParticipant")]
177        /// All participants on the share that the current user has permissions to see.
178        ///
179        ///
180        /// At the minimum that will include the owner and the current user.
181        #[unsafe(method(participants))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn participants(&self) -> Retained<NSArray<CKShareParticipant>>;
184
185        #[cfg(feature = "CKShareParticipant")]
186        /// Convenience methods for fetching special users from the participant array
187        #[unsafe(method(owner))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn owner(&self) -> Retained<CKShareParticipant>;
190
191        #[cfg(feature = "CKShareParticipant")]
192        #[unsafe(method(currentUserParticipant))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn currentUserParticipant(&self) -> Option<Retained<CKShareParticipant>>;
195
196        #[cfg(feature = "CKShareParticipant")]
197        /// If a participant with a matching userIdentity already exists, then that existing participant's properties will be updated; no new participant will be added.
198        /// 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`.
199        /// In order to modify the list of participants, a share must have publicPermission set to
200        /// `CKShareParticipantPermissionNone.`That is, you cannot mix-and-match private users and public users in the same share.
201        ///
202        /// See: CKShareParticipantRole
203        #[unsafe(method(addParticipant:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn addParticipant(&self, participant: &CKShareParticipant);
206
207        #[cfg(feature = "CKShareParticipant")]
208        /// It's not allowed to call `removeParticipant` on a ``CKShare`` with a ``CKShareParticipant`` that has never been added to that share through `addParticipant`.
209        #[unsafe(method(removeParticipant:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn removeParticipant(&self, participant: &CKShareParticipant);
212
213        /// Invitation URLs that can be used by any receiver to claim the associated participantID and join the share.
214        ///
215        /// Only available after a share record has been saved to the server for participants created via ``CKShareParticipant/oneTimeURLParticipant``.
216        /// One-time URLs are stable, and tied to the associated participantIDs as long as the participant is part of the share.
217        /// Typically, a recipient user invited via their handle is provided a ``URL`` directly by the share's owner.
218        /// However, any user can also use a one-time URL in the same manner to fetch share metadata and accept the share.
219        /// After share acceptance, the one-time URL becomes functionally equivalent to the regular ``URL``.
220        ///
221        /// - Parameters:
222        /// - participantID: The ``CKShareParticipant/participantID`` corresponding to the ``CKShareParticipant/oneTimeURLParticipant`` added to the share.
223        #[unsafe(method(oneTimeURLForParticipantID:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn oneTimeURLForParticipantID(
226            &self,
227            participant_id: &NSString,
228        ) -> Option<Retained<NSURL>>;
229
230        /// These superclass-provided initializers are not allowed for CKShare
231        #[unsafe(method(init))]
232        #[unsafe(method_family = init)]
233        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
234
235        #[unsafe(method(new))]
236        #[unsafe(method_family = new)]
237        pub unsafe fn new() -> Retained<Self>;
238
239        #[unsafe(method(initWithRecordType:))]
240        #[unsafe(method_family = init)]
241        pub unsafe fn initWithRecordType(
242            this: Allocated<Self>,
243            record_type: &CKRecordType,
244        ) -> Retained<Self>;
245
246        #[cfg(feature = "CKRecordID")]
247        #[unsafe(method(initWithRecordType:recordID:))]
248        #[unsafe(method_family = init)]
249        pub unsafe fn initWithRecordType_recordID(
250            this: Allocated<Self>,
251            record_type: &CKRecordType,
252            record_id: &CKRecordID,
253        ) -> Retained<Self>;
254
255        #[cfg(feature = "CKRecordZoneID")]
256        #[unsafe(method(initWithRecordType:zoneID:))]
257        #[unsafe(method_family = init)]
258        pub unsafe fn initWithRecordType_zoneID(
259            this: Allocated<Self>,
260            record_type: &CKRecordType,
261            zone_id: &CKRecordZoneID,
262        ) -> Retained<Self>;
263
264        #[cfg(feature = "CKShareAccessRequester")]
265        /// A list of all uninvited users who have requested access to this share.
266        ///
267        /// When share access requests are allowed, uninvited users can request to join the share.
268        /// All pending access requests appear in this array. Each requester is returned with name components
269        /// and either an email or phone number.
270        ///
271        /// Either share owners or administrators can respond to these access requests.
272        ///
273        /// ### Responding to Access Requests:
274        ///
275        /// - **Approve Requesters:**
276        /// - Fetch the participant information by running ``CKFetchShareParticipantsOperation`` with
277        /// the requester's ``CKShareAccessRequester/participantLookupInfo``.
278        /// - Add the resulting participant to the share.
279        ///
280        /// - **Deny Requesters:**
281        /// - Use ``CloudKit/CKShare/denyRequesters:`` to remove the requester from the requesters list.
282        ///
283        /// - **Block Requesters:**
284        /// - Use ``CloudKit/CKShare/blockRequesters:`` to block requesters.
285        /// - Blocking a requester prevents them from sending future access requests to the share.
286        #[unsafe(method(requesters))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn requesters(&self) -> Retained<NSArray<CKShareAccessRequester>>;
289
290        #[cfg(feature = "CKShareBlockedIdentity")]
291        /// A list of users blocked from requesting access to this share.
292        ///
293        /// Identities remain in this list until an owner or administrator calls ``CloudKit/CKShare/unblockIdentities:``.
294        #[unsafe(method(blockedIdentities))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn blockedIdentities(&self) -> Retained<NSArray<CKShareBlockedIdentity>>;
297
298        /// Indicates whether uninvited users can request access to this share.
299        ///
300        /// By default, this property is set to `NO`. When set to `YES`, uninvited users can request
301        /// access to the share if they discover the share URL. When set to `NO`, the server prevents uninvited users
302        /// from requesting access and does not indicate whether the share exists.
303        ///
304        /// Only the share owner or an administrator can modify this property. Attempts by other participants
305        /// to modify this property result in an exception.
306        #[unsafe(method(allowsAccessRequests))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn allowsAccessRequests(&self) -> bool;
309
310        /// Setter for [`allowsAccessRequests`][Self::allowsAccessRequests].
311        #[unsafe(method(setAllowsAccessRequests:))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn setAllowsAccessRequests(&self, allows_access_requests: bool);
314
315        #[cfg(feature = "CKShareAccessRequester")]
316        /// Denies access requests from specified users.
317        ///
318        /// Use this method to deny pending access requests from uninvited users. Denied requesters are removed
319        /// from the ``CloudKit/CKShare/requesters`` array. To persist the changes, save the share to the server
320        /// after calling this method.
321        ///
322        /// After denial, requesters can still submit new access requests unless explicitly blocked using
323        /// ``CloudKit/CKShare/blockRequesters:``.
324        ///
325        /// Only the share owner or an administrator can invoke this method. Attempts by other participants
326        /// result in an exception.
327        ///
328        /// - Parameter requesters: An array of ``CKShareAccessRequester`` objects to deny.
329        #[unsafe(method(denyRequesters:))]
330        #[unsafe(method_family = none)]
331        pub unsafe fn denyRequesters(&self, requesters: &NSArray<CKShareAccessRequester>);
332
333        #[cfg(feature = "CKShareAccessRequester")]
334        /// Blocks specified users from requesting access to this share.
335        ///
336        /// Blocking prevents users from submitting future access requests and removes existing participants from the share.
337        /// Blocked requesters appear in the ``CloudKit/CKShare/blockedIdentities`` array.
338        ///
339        /// To persist this change, save the share to the server after calling this method.
340        ///
341        /// Only the share owner or an administrator can invoke this method. Attempts by other participants
342        /// result in an exception.
343        ///
344        /// - Parameter requesters: An array of ``CKShareAccessRequester`` objects to block.
345        #[unsafe(method(blockRequesters:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn blockRequesters(&self, requesters: &NSArray<CKShareAccessRequester>);
348
349        #[cfg(feature = "CKShareBlockedIdentity")]
350        /// Unblocks previously blocked users, allowing them to request access again.
351        ///
352        /// Use this method to remove specified identities from the ``CloudKit/CKShare/blockedIdentities`` array.
353        /// Unblocked identities can request access again if access requests are enabled.
354        ///
355        /// To persist this change, save the share to the server after calling this method.
356        ///
357        /// Only the share owner or an administrator can invoke this method. Attempts by other participants
358        /// result in an exception.
359        ///
360        /// - Parameter blockedIdentities: An array of ``CKShareBlockedIdentity`` objects to unblock.
361        #[unsafe(method(unblockIdentities:))]
362        #[unsafe(method_family = none)]
363        pub unsafe fn unblockIdentities(
364            &self,
365            blocked_identities: &NSArray<CKShareBlockedIdentity>,
366        );
367    );
368}