objc2_cloud_kit/generated/CKRecord.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::*;
6#[cfg(feature = "objc2-core-location")]
7use objc2_core_location::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordtype?language=objc)
13pub type CKRecordType = NSString;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordfieldkey?language=objc)
16pub type CKRecordFieldKey = NSString;
17
18extern "C" {
19 /// Use this constant for the recordType parameter when fetching User Records.
20 ///
21 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordtypeuserrecord?language=objc)
22 pub static CKRecordTypeUserRecord: &'static CKRecordType;
23}
24
25extern "C" {
26 /// For use in queries to match on record properties. Matches `record.recordID`. Value is a `CKRecordID`
27 ///
28 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordrecordidkey?language=objc)
29 pub static CKRecordRecordIDKey: &'static CKRecordFieldKey;
30}
31
32extern "C" {
33 /// For use in queries to match on record properties. Matches `record.creatorUserRecordID`. Value is a `CKRecordID`
34 ///
35 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordcreatoruserrecordidkey?language=objc)
36 pub static CKRecordCreatorUserRecordIDKey: &'static CKRecordFieldKey;
37}
38
39extern "C" {
40 /// For use in queries to match on record properties. Matches `record.creationDate`. Value is a `NSDate`
41 ///
42 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordcreationdatekey?language=objc)
43 pub static CKRecordCreationDateKey: &'static CKRecordFieldKey;
44}
45
46extern "C" {
47 /// For use in queries to match on record properties. Matches `record.lastModifiedUserRecordID`. Value is a `CKRecordID`
48 ///
49 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordlastmodifieduserrecordidkey?language=objc)
50 pub static CKRecordLastModifiedUserRecordIDKey: &'static CKRecordFieldKey;
51}
52
53extern "C" {
54 /// For use in queries to match on record properties. Matches `record.modificationDate`. Value is a `NSDate`
55 ///
56 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordmodificationdatekey?language=objc)
57 pub static CKRecordModificationDateKey: &'static CKRecordFieldKey;
58}
59
60extern "C" {
61 /// For use in queries to match on record properties. Matches `record.parent`
62 ///
63 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordparentkey?language=objc)
64 pub static CKRecordParentKey: &'static CKRecordFieldKey;
65}
66
67extern "C" {
68 /// For use in queries to match on record properties. Matches `record.share`
69 ///
70 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordsharekey?language=objc)
71 pub static CKRecordShareKey: &'static CKRecordFieldKey;
72}
73
74extern_protocol!(
75 /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordvalue?language=objc)
76 pub unsafe trait CKRecordValue: NSObjectProtocol {}
77);
78
79extern_class!(
80 /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecord?language=objc)
81 #[unsafe(super(NSObject))]
82 #[derive(Debug, PartialEq, Eq, Hash)]
83 pub struct CKRecord;
84);
85
86unsafe impl NSCoding for CKRecord {}
87
88unsafe impl NSCopying for CKRecord {}
89
90unsafe impl CopyingHelper for CKRecord {
91 type Result = Self;
92}
93
94unsafe impl NSObjectProtocol for CKRecord {}
95
96unsafe impl NSSecureCoding for CKRecord {}
97
98impl CKRecord {
99 extern_methods!(
100 #[unsafe(method(init))]
101 #[unsafe(method_family = init)]
102 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
103
104 #[unsafe(method(new))]
105 #[unsafe(method_family = new)]
106 pub unsafe fn new() -> Retained<Self>;
107
108 /// This creates the record in the default zone.
109 #[unsafe(method(initWithRecordType:))]
110 #[unsafe(method_family = init)]
111 pub unsafe fn initWithRecordType(
112 this: Allocated<Self>,
113 record_type: &CKRecordType,
114 ) -> Retained<Self>;
115
116 #[cfg(feature = "CKRecordID")]
117 #[unsafe(method(initWithRecordType:recordID:))]
118 #[unsafe(method_family = init)]
119 pub unsafe fn initWithRecordType_recordID(
120 this: Allocated<Self>,
121 record_type: &CKRecordType,
122 record_id: &CKRecordID,
123 ) -> Retained<Self>;
124
125 #[cfg(feature = "CKRecordZoneID")]
126 #[unsafe(method(initWithRecordType:zoneID:))]
127 #[unsafe(method_family = init)]
128 pub unsafe fn initWithRecordType_zoneID(
129 this: Allocated<Self>,
130 record_type: &CKRecordType,
131 zone_id: &CKRecordZoneID,
132 ) -> Retained<Self>;
133
134 #[unsafe(method(recordType))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn recordType(&self) -> Retained<CKRecordType>;
137
138 #[cfg(feature = "CKRecordID")]
139 #[unsafe(method(recordID))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn recordID(&self) -> Retained<CKRecordID>;
142
143 /// Change tags are updated by the server to a unique value every time a record is modified. A different change tag necessarily means that the contents of the record are different.
144 #[unsafe(method(recordChangeTag))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn recordChangeTag(&self) -> Option<Retained<NSString>>;
147
148 #[cfg(feature = "CKRecordID")]
149 /// This is a User Record recordID, identifying the user that created this record.
150 #[unsafe(method(creatorUserRecordID))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn creatorUserRecordID(&self) -> Option<Retained<CKRecordID>>;
153
154 #[unsafe(method(creationDate))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn creationDate(&self) -> Option<Retained<NSDate>>;
157
158 #[cfg(feature = "CKRecordID")]
159 /// This is a User Record recordID, identifying the user that last modified this record.
160 #[unsafe(method(lastModifiedUserRecordID))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn lastModifiedUserRecordID(&self) -> Option<Retained<CKRecordID>>;
163
164 #[unsafe(method(modificationDate))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn modificationDate(&self) -> Option<Retained<NSDate>>;
167
168 /// In addition to
169 /// `objectForKey:`and
170 /// `setObject:forKey:,`dictionary-style subscripting (
171 /// `record[key]`and
172 ///
173 /// ```text
174 /// record[key] = value
175 /// ```
176 ///
177 /// ) can be used to get and set values.
178 /// Acceptable value object classes are:
179 /// - CKReference
180 /// - CKAsset
181 /// - CLLocation
182 /// - NSData
183 /// - NSDate
184 /// - NSNumber
185 /// - NSString
186 /// - NSArray containing objects of any of the types above
187 ///
188 /// Any other classes will result in an exception with name
189 /// `NSInvalidArgumentException.`
190 /// Whenever possible, value objects will be copied when set on a record.
191 ///
192 /// Field keys starting with '_' are reserved. Attempting to set a key prefixed with a '_' will result in an error.
193 ///
194 /// Key names roughly match C variable name restrictions. They must begin with an ASCII letter and can contain ASCII letters and numbers and the underscore character.
195 /// The maximum key length is 255 characters.
196 #[unsafe(method(objectForKey:))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn objectForKey(
199 &self,
200 key: &CKRecordFieldKey,
201 ) -> Option<Retained<ProtocolObject<dyn CKRecordValue>>>;
202
203 #[unsafe(method(setObject:forKey:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn setObject_forKey(
206 &self,
207 object: Option<&ProtocolObject<dyn CKRecordValue>>,
208 key: &CKRecordFieldKey,
209 );
210
211 #[unsafe(method(allKeys))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn allKeys(&self) -> Retained<NSArray<CKRecordFieldKey>>;
214
215 /// A special property that returns an array of token generated from all the string field values in the record.
216 ///
217 ///
218 /// These tokens have been normalized for the current locale, so they are suitable for performing full-text searches.
219 #[unsafe(method(allTokens))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn allTokens(&self) -> Retained<NSArray<NSString>>;
222
223 #[unsafe(method(objectForKeyedSubscript:))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn objectForKeyedSubscript(
226 &self,
227 key: &CKRecordFieldKey,
228 ) -> Option<Retained<ProtocolObject<dyn CKRecordValue>>>;
229
230 #[unsafe(method(setObject:forKeyedSubscript:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn setObject_forKeyedSubscript(
233 &self,
234 object: Option<&ProtocolObject<dyn CKRecordValue>>,
235 key: &CKRecordFieldKey,
236 );
237
238 /// A list of keys that have been modified on the local CKRecord instance
239 #[unsafe(method(changedKeys))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn changedKeys(&self) -> Retained<NSArray<CKRecordFieldKey>>;
242
243 /// `CKRecord`supports
244 /// `NSSecureCoding.`When you invoke
245 /// `encodeWithCoder:`on a
246 /// `CKRecord,`it encodes all its values. Including the record values you've set.
247 /// If you want to store a
248 /// `CKRecord`instance locally, AND you're already storing the record values locally, that's overkill. In that case, you can use
249 /// `encodeSystemFieldsWithCoder:.`This will encode all parts of a
250 /// `CKRecord`except the record keys / values you have access to via the
251 /// `changedKeys`and
252 /// `objectForKey:`methods.
253 /// If you use
254 /// `initWithCoder:`to reconstitute a
255 /// `CKRecord`you encoded via
256 /// `encodeSystemFieldsWithCoder:,`then be aware that
257 /// - any record values you had set on the original instance, but had not saved, will be lost
258 /// - the reconstituted CKRecord's
259 /// `changedKeys`will be empty
260 #[unsafe(method(encodeSystemFieldsWithCoder:))]
261 #[unsafe(method_family = none)]
262 pub unsafe fn encodeSystemFieldsWithCoder(&self, coder: &NSCoder);
263
264 #[cfg(feature = "CKReference")]
265 /// The share property on a record can be set by creating a share using
266 ///
267 /// ```text
268 /// -[CKShare initWithRootRecord:]
269 /// ```
270 ///
271 /// .
272 ///
273 /// The share property on a record will be removed when the corresponding CKShare is deleted from the server. Send this record in the same batch as the share delete and this record's share property will be updated.
274 ///
275 /// Sharing is only supported in zones with the
276 /// `CKRecordZoneCapabilitySharing`capability. The default zone does not support sharing.
277 ///
278 /// If any records have a parent reference to this record, they are implicitly shared alongside this record.
279 ///
280 /// Note that records in a parent chain must only exist within one share. If a child record already has a share reference set then you will get a
281 /// `CKErrorAlreadyShared`error if you try to share any of that record's parents.
282 ///
283 /// Child records can be shared independently, even if they have a common parent. For example:
284 /// Record A has two child records, Record B and Record C.
285 /// A
286 /// /
287 /// \
288 /// B C
289 ///
290 /// These configurations are supported:
291 /// - Record A part of Share 1, or
292 /// - Record B part of Share 1, or
293 /// - Record C part of Share 1, or
294 /// - Record B part of Share 1, Record C part of Share 2
295 ///
296 /// These configurations are not supported:
297 /// Record A part of Share 1, Record B part of Share 2, or
298 /// -- This is not allowed because Record B would then be in two shares; Share 1 by being Record A's child, and Share 2
299 /// Record A part of Share 1, Record C part of Share 2, or
300 /// -- This is not allowed because Record C would then be in two shares; Share 1 by being Record A's child, and Share 2
301 /// Record A part of Share 1, Record B part of Share 2, Record C part of Share 3
302 /// -- This is not allowed because both Record B and Record C would then each be in two shares.
303 ///
304 /// Whenever possible, it is suggested that you construct your parent hierarchies such that you will only need to share the topmost record of that hierarchy.
305 #[unsafe(method(share))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn share(&self) -> Option<Retained<CKReference>>;
308
309 #[cfg(feature = "CKReference")]
310 /// Use a parent reference to teach CloudKit about the hierarchy of your records.
311 ///
312 ///
313 /// When a record is shared, all children of that record are also shared.
314 ///
315 /// A parent record reference must have
316 /// `CKReferenceActionNone`set. You can create a separate reference with
317 /// `CKReferenceActionDeleteSelf`if you would like your hierarchy cleaned up when the parent record is deleted.
318 ///
319 /// The target of a parent reference must exist at save time - either already on the server, or part of the same
320 /// `CKModifyRecordsOperation`batch.
321 ///
322 /// You are encouraged to set up the
323 /// `parent`relationships as part of normal record saves, even if you're not planning on sharing records at this time.
324 /// This allows you to share and unshare a hierarchy of records at a later date by only modifying the "top level" record, setting or clearing its
325 /// `share`reference.
326 #[unsafe(method(parent))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn parent(&self) -> Option<Retained<CKReference>>;
329
330 #[cfg(feature = "CKReference")]
331 /// Setter for [`parent`][Self::parent].
332 #[unsafe(method(setParent:))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn setParent(&self, parent: Option<&CKReference>);
335
336 /// Convenience wrappers around creating a
337 /// `CKReference`to a parent record. The resulting
338 /// `CKReference`will have
339 ///
340 /// ```text
341 /// referenceAction = CKReferenceActionNone
342 /// ```
343 #[unsafe(method(setParentReferenceFromRecord:))]
344 #[unsafe(method_family = none)]
345 pub unsafe fn setParentReferenceFromRecord(&self, parent_record: Option<&CKRecord>);
346
347 #[cfg(feature = "CKRecordID")]
348 #[unsafe(method(setParentReferenceFromRecordID:))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn setParentReferenceFromRecordID(&self, parent_record_id: Option<&CKRecordID>);
351 );
352}
353
354unsafe impl CKRecordValue for NSString {}
355
356unsafe impl CKRecordValue for NSNumber {}
357
358unsafe impl CKRecordValue for NSArray {}
359
360unsafe impl CKRecordValue for NSDate {}
361
362unsafe impl CKRecordValue for NSData {}
363
364/// CKRecordValue.
365#[cfg(feature = "CKReference")]
366impl CKReference {
367 extern_methods!();
368}
369
370#[cfg(feature = "CKReference")]
371unsafe impl CKRecordValue for CKReference {}
372
373/// CKRecordValue.
374#[cfg(feature = "CKAsset")]
375impl CKAsset {
376 extern_methods!();
377}
378
379#[cfg(feature = "CKAsset")]
380unsafe impl CKRecordValue for CKAsset {}
381
382#[cfg(feature = "objc2-core-location")]
383unsafe impl CKRecordValue for CLLocation {}
384
385extern_protocol!(
386 /// Formalizes a protocol for getting and setting keys on a CKRecord. Not intended to be used directly by client code
387 ///
388 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordkeyvaluesetting?language=objc)
389 pub unsafe trait CKRecordKeyValueSetting: NSObjectProtocol {
390 #[unsafe(method(objectForKey:))]
391 #[unsafe(method_family = none)]
392 unsafe fn objectForKey(
393 &self,
394 key: &CKRecordFieldKey,
395 ) -> Option<Retained<ProtocolObject<dyn CKRecordValue>>>;
396
397 #[unsafe(method(setObject:forKey:))]
398 #[unsafe(method_family = none)]
399 unsafe fn setObject_forKey(
400 &self,
401 object: Option<&ProtocolObject<dyn CKRecordValue>>,
402 key: &CKRecordFieldKey,
403 );
404
405 #[unsafe(method(objectForKeyedSubscript:))]
406 #[unsafe(method_family = none)]
407 unsafe fn objectForKeyedSubscript(
408 &self,
409 key: &CKRecordFieldKey,
410 ) -> Option<Retained<ProtocolObject<dyn CKRecordValue>>>;
411
412 #[unsafe(method(setObject:forKeyedSubscript:))]
413 #[unsafe(method_family = none)]
414 unsafe fn setObject_forKeyedSubscript(
415 &self,
416 object: Option<&ProtocolObject<dyn CKRecordValue>>,
417 key: &CKRecordFieldKey,
418 );
419
420 #[unsafe(method(allKeys))]
421 #[unsafe(method_family = none)]
422 unsafe fn allKeys(&self) -> Retained<NSArray<CKRecordFieldKey>>;
423
424 #[unsafe(method(changedKeys))]
425 #[unsafe(method_family = none)]
426 unsafe fn changedKeys(&self) -> Retained<NSArray<CKRecordFieldKey>>;
427 }
428);
429
430/// CKRecordKeyValueSettingConformance.
431impl CKRecord {
432 extern_methods!(
433 /// Any values set here will be locally encrypted before being saved to the server and locally decrypted when fetched from the server. Encryption and decryption is handled by the CloudKit framework.
434 /// Key material necessary for decryption are available to the owner of the record, as well as any users that can access this record via a CKShare.
435 /// All CKRecordValue types can be set here except CKAsset and CKReference.
436 #[unsafe(method(encryptedValues))]
437 #[unsafe(method_family = none)]
438 pub unsafe fn encryptedValues(
439 &self,
440 ) -> Retained<ProtocolObject<dyn CKRecordKeyValueSetting>>;
441 );
442}
443
444unsafe impl CKRecordKeyValueSetting for CKRecord {}