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")]
68unsafe impl NSCoding for CKShare {}
69
70#[cfg(feature = "CKRecord")]
71unsafe impl NSCopying for CKShare {}
72
73#[cfg(feature = "CKRecord")]
74unsafe impl CopyingHelper for CKShare {
75 type Result = Self;
76}
77
78#[cfg(feature = "CKRecord")]
79unsafe impl NSObjectProtocol for CKShare {}
80
81#[cfg(feature = "CKRecord")]
82unsafe impl NSSecureCoding for CKShare {}
83
84#[cfg(feature = "CKRecord")]
85impl CKShare {
86 extern_methods!(
87 /// When saving a newly created CKShare, you must save the share and its rootRecord in the same CKModifyRecordsOperation batch.
88 #[unsafe(method(initWithRootRecord:))]
89 #[unsafe(method_family = init)]
90 pub unsafe fn initWithRootRecord(
91 this: Allocated<Self>,
92 root_record: &CKRecord,
93 ) -> Retained<Self>;
94
95 #[cfg(feature = "CKRecordID")]
96 #[unsafe(method(initWithRootRecord:shareID:))]
97 #[unsafe(method_family = init)]
98 pub unsafe fn initWithRootRecord_shareID(
99 this: Allocated<Self>,
100 root_record: &CKRecord,
101 share_id: &CKRecordID,
102 ) -> Retained<Self>;
103
104 #[cfg(feature = "CKRecordZoneID")]
105 /// Creates a zone-wide
106 /// `CKShare.`A zone-wide
107 /// `CKShare`can only exist in a zone with sharing capability
108 /// `CKRecordZoneCapabilityZoneWideSharing.`Only one such share can exist in a zone at a time.
109 ///
110 /// All records in this zone will appear in a participant's
111 /// `CKFetchRecordZoneChangesOperation`results in the shared database after the
112 /// share has been accepted by the participant.
113 ///
114 /// Since these shares do not have an associated root record,
115 /// `shouldFetchRootRecord`and
116 /// `rootRecordDesiredKeys`are always ignored when
117 /// running a
118 /// `CKFetchShareMetadataOperation`on a zone-wide share URL. Additionally,
119 /// `rootRecordID`on the resulting
120 /// `CKShareMetadata`is
121 /// always absent.
122 #[unsafe(method(initWithRecordZoneID:))]
123 #[unsafe(method_family = init)]
124 pub unsafe fn initWithRecordZoneID(
125 this: Allocated<Self>,
126 record_zone_id: &CKRecordZoneID,
127 ) -> Retained<Self>;
128
129 #[unsafe(method(initWithCoder:))]
130 #[unsafe(method_family = init)]
131 pub unsafe fn initWithCoder(this: Allocated<Self>, a_decoder: &NSCoder) -> Retained<Self>;
132
133 #[cfg(feature = "CKShareParticipant")]
134 /// Defines what permission a user has when not explicitly added to the share.
135 ///
136 ///
137 /// Shares with
138 /// `publicPermission`more permissive than
139 /// `CKShareParticipantPermissionNone`can be joined by any user with access to the share's shareURL.
140 /// By default, public permission is
141 /// `CKShareParticipantPermissionNone.`Changing the public permission to
142 /// `CKShareParticipantPermissionReadOnly`or
143 /// `CKShareParticipantPermissionReadWrite`will result in all pending participants being removed. Already-accepted participants will remain on the share.
144 /// Changing the public permission to
145 /// `CKShareParticipantPermissionNone`will result in all participants being removed from the share. You may subsequently choose to call
146 /// `addParticipant:`before saving the share, those participants will be added to the share.
147 #[unsafe(method(publicPermission))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn publicPermission(&self) -> CKShareParticipantPermission;
150
151 #[cfg(feature = "CKShareParticipant")]
152 /// Setter for [`publicPermission`][Self::publicPermission].
153 #[unsafe(method(setPublicPermission:))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn setPublicPermission(&self, public_permission: CKShareParticipantPermission);
156
157 /// A URL that can be used to invite participants to this share.
158 ///
159 ///
160 /// 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
161 #[unsafe(method(URL))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
164
165 #[cfg(feature = "CKShareParticipant")]
166 /// All participants on the share that the current user has permissions to see.
167 ///
168 ///
169 /// At the minimum that will include the owner and the current user.
170 #[unsafe(method(participants))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn participants(&self) -> Retained<NSArray<CKShareParticipant>>;
173
174 #[cfg(feature = "CKShareParticipant")]
175 /// Convenience methods for fetching special users from the participant array
176 #[unsafe(method(owner))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn owner(&self) -> Retained<CKShareParticipant>;
179
180 #[cfg(feature = "CKShareParticipant")]
181 #[unsafe(method(currentUserParticipant))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn currentUserParticipant(&self) -> Option<Retained<CKShareParticipant>>;
184
185 #[cfg(feature = "CKShareParticipant")]
186 /// If a participant with a matching userIdentity already exists, then that existing participant's properties will be updated; no new participant will be added.
187 /// 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`.
188 /// In order to modify the list of participants, a share must have publicPermission set to
189 /// `CKShareParticipantPermissionNone.`That is, you cannot mix-and-match private users and public users in the same share.
190 ///
191 /// See: CKShareParticipantRole
192 #[unsafe(method(addParticipant:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn addParticipant(&self, participant: &CKShareParticipant);
195
196 #[cfg(feature = "CKShareParticipant")]
197 /// It's not allowed to call `removeParticipant` on a `CKShare` with a `CKShareParticipant` that has never been added to that share through `addParticipant`.
198 #[unsafe(method(removeParticipant:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn removeParticipant(&self, participant: &CKShareParticipant);
201
202 /// These superclass-provided initializers are not allowed for CKShare
203 #[unsafe(method(init))]
204 #[unsafe(method_family = init)]
205 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
206
207 #[unsafe(method(new))]
208 #[unsafe(method_family = new)]
209 pub unsafe fn new() -> Retained<Self>;
210
211 #[unsafe(method(initWithRecordType:))]
212 #[unsafe(method_family = init)]
213 pub unsafe fn initWithRecordType(
214 this: Allocated<Self>,
215 record_type: &CKRecordType,
216 ) -> Retained<Self>;
217
218 #[cfg(feature = "CKRecordID")]
219 #[unsafe(method(initWithRecordType:recordID:))]
220 #[unsafe(method_family = init)]
221 pub unsafe fn initWithRecordType_recordID(
222 this: Allocated<Self>,
223 record_type: &CKRecordType,
224 record_id: &CKRecordID,
225 ) -> Retained<Self>;
226
227 #[cfg(feature = "CKRecordZoneID")]
228 #[unsafe(method(initWithRecordType:zoneID:))]
229 #[unsafe(method_family = init)]
230 pub unsafe fn initWithRecordType_zoneID(
231 this: Allocated<Self>,
232 record_type: &CKRecordType,
233 zone_id: &CKRecordZoneID,
234 ) -> Retained<Self>;
235 );
236}