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        #[unsafe(method(initWithCoder:))]
138        #[unsafe(method_family = init)]
139        pub unsafe fn initWithCoder(this: Allocated<Self>, a_decoder: &NSCoder) -> Retained<Self>;
140
141        #[cfg(feature = "CKShareParticipant")]
142        /// Defines what permission a user has when not explicitly added to the share.
143        ///
144        ///
145        /// Shares with
146        /// `publicPermission`more permissive than
147        /// `CKShareParticipantPermissionNone`can be joined by any user with access to the share's shareURL.
148        /// By default, public permission is
149        /// `CKShareParticipantPermissionNone.`Changing the public permission to
150        /// `CKShareParticipantPermissionReadOnly`or
151        /// `CKShareParticipantPermissionReadWrite`will result in all pending participants being removed.  Already-accepted participants will remain on the share.
152        /// Changing the public permission to
153        /// `CKShareParticipantPermissionNone`will result in all participants being removed from the share.  You may subsequently choose to call
154        /// `addParticipant:`before saving the share, those participants will be added to the share.
155        #[unsafe(method(publicPermission))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn publicPermission(&self) -> CKShareParticipantPermission;
158
159        #[cfg(feature = "CKShareParticipant")]
160        /// Setter for [`publicPermission`][Self::publicPermission].
161        #[unsafe(method(setPublicPermission:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn setPublicPermission(&self, public_permission: CKShareParticipantPermission);
164
165        /// A URL that can be used to invite participants to this share.
166        ///
167        ///
168        /// 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
169        #[unsafe(method(URL))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
172
173        #[cfg(feature = "CKShareParticipant")]
174        /// All participants on the share that the current user has permissions to see.
175        ///
176        ///
177        /// At the minimum that will include the owner and the current user.
178        #[unsafe(method(participants))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn participants(&self) -> Retained<NSArray<CKShareParticipant>>;
181
182        #[cfg(feature = "CKShareParticipant")]
183        /// Convenience methods for fetching special users from the participant array
184        #[unsafe(method(owner))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn owner(&self) -> Retained<CKShareParticipant>;
187
188        #[cfg(feature = "CKShareParticipant")]
189        #[unsafe(method(currentUserParticipant))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn currentUserParticipant(&self) -> Option<Retained<CKShareParticipant>>;
192
193        #[cfg(feature = "CKShareParticipant")]
194        /// If a participant with a matching userIdentity already exists, then that existing participant's properties will be updated; no new participant will be added.
195        /// 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`.
196        /// In order to modify the list of participants, a share must have publicPermission set to
197        /// `CKShareParticipantPermissionNone.`That is, you cannot mix-and-match private users and public users in the same share.
198        ///
199        /// See: CKShareParticipantRole
200        #[unsafe(method(addParticipant:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn addParticipant(&self, participant: &CKShareParticipant);
203
204        #[cfg(feature = "CKShareParticipant")]
205        /// It's not allowed to call `removeParticipant` on a `CKShare` with a `CKShareParticipant` that has never been added to that share through `addParticipant`.
206        #[unsafe(method(removeParticipant:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn removeParticipant(&self, participant: &CKShareParticipant);
209
210        /// These superclass-provided initializers are not allowed for CKShare
211        #[unsafe(method(init))]
212        #[unsafe(method_family = init)]
213        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
214
215        #[unsafe(method(new))]
216        #[unsafe(method_family = new)]
217        pub unsafe fn new() -> Retained<Self>;
218
219        #[unsafe(method(initWithRecordType:))]
220        #[unsafe(method_family = init)]
221        pub unsafe fn initWithRecordType(
222            this: Allocated<Self>,
223            record_type: &CKRecordType,
224        ) -> Retained<Self>;
225
226        #[cfg(feature = "CKRecordID")]
227        #[unsafe(method(initWithRecordType:recordID:))]
228        #[unsafe(method_family = init)]
229        pub unsafe fn initWithRecordType_recordID(
230            this: Allocated<Self>,
231            record_type: &CKRecordType,
232            record_id: &CKRecordID,
233        ) -> Retained<Self>;
234
235        #[cfg(feature = "CKRecordZoneID")]
236        #[unsafe(method(initWithRecordType:zoneID:))]
237        #[unsafe(method_family = init)]
238        pub unsafe fn initWithRecordType_zoneID(
239            this: Allocated<Self>,
240            record_type: &CKRecordType,
241            zone_id: &CKRecordZoneID,
242        ) -> Retained<Self>;
243    );
244}