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
86extern_conformance!(
87 unsafe impl NSCoding for CKRecord {}
88);
89
90extern_conformance!(
91 unsafe impl NSCopying for CKRecord {}
92);
93
94unsafe impl CopyingHelper for CKRecord {
95 type Result = Self;
96}
97
98extern_conformance!(
99 unsafe impl NSObjectProtocol for CKRecord {}
100);
101
102extern_conformance!(
103 unsafe impl NSSecureCoding for CKRecord {}
104);
105
106impl CKRecord {
107 extern_methods!(
108 #[unsafe(method(init))]
109 #[unsafe(method_family = init)]
110 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
111
112 #[unsafe(method(new))]
113 #[unsafe(method_family = new)]
114 pub unsafe fn new() -> Retained<Self>;
115
116 /// This creates the record in the default zone.
117 #[unsafe(method(initWithRecordType:))]
118 #[unsafe(method_family = init)]
119 pub unsafe fn initWithRecordType(
120 this: Allocated<Self>,
121 record_type: &CKRecordType,
122 ) -> Retained<Self>;
123
124 #[cfg(feature = "CKRecordID")]
125 #[unsafe(method(initWithRecordType:recordID:))]
126 #[unsafe(method_family = init)]
127 pub unsafe fn initWithRecordType_recordID(
128 this: Allocated<Self>,
129 record_type: &CKRecordType,
130 record_id: &CKRecordID,
131 ) -> Retained<Self>;
132
133 #[cfg(feature = "CKRecordZoneID")]
134 #[unsafe(method(initWithRecordType:zoneID:))]
135 #[unsafe(method_family = init)]
136 pub unsafe fn initWithRecordType_zoneID(
137 this: Allocated<Self>,
138 record_type: &CKRecordType,
139 zone_id: &CKRecordZoneID,
140 ) -> Retained<Self>;
141
142 #[unsafe(method(recordType))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn recordType(&self) -> Retained<CKRecordType>;
145
146 #[cfg(feature = "CKRecordID")]
147 #[unsafe(method(recordID))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn recordID(&self) -> Retained<CKRecordID>;
150
151 /// 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.
152 #[unsafe(method(recordChangeTag))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn recordChangeTag(&self) -> Option<Retained<NSString>>;
155
156 #[cfg(feature = "CKRecordID")]
157 /// This is a User Record recordID, identifying the user that created this record.
158 #[unsafe(method(creatorUserRecordID))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn creatorUserRecordID(&self) -> Option<Retained<CKRecordID>>;
161
162 #[unsafe(method(creationDate))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn creationDate(&self) -> Option<Retained<NSDate>>;
165
166 #[cfg(feature = "CKRecordID")]
167 /// This is a User Record recordID, identifying the user that last modified this record.
168 #[unsafe(method(lastModifiedUserRecordID))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn lastModifiedUserRecordID(&self) -> Option<Retained<CKRecordID>>;
171
172 #[unsafe(method(modificationDate))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn modificationDate(&self) -> Option<Retained<NSDate>>;
175
176 /// In addition to
177 /// `objectForKey:`and
178 /// `setObject:forKey:,`dictionary-style subscripting (
179 /// `record[key]`and
180 ///
181 /// ```text
182 /// record[key] = value
183 /// ```
184 ///
185 /// ) can be used to get and set values.
186 /// Acceptable value object classes are:
187 /// - CKReference
188 /// - CKAsset
189 /// - CLLocation
190 /// - NSData
191 /// - NSDate
192 /// - NSNumber
193 /// - NSString
194 /// - NSArray containing objects of any of the types above
195 ///
196 /// Any other classes will result in an exception with name
197 /// `NSInvalidArgumentException.`
198 /// Whenever possible, value objects will be copied when set on a record.
199 ///
200 /// Field keys starting with '_' are reserved. Attempting to set a key prefixed with a '_' will result in an error.
201 ///
202 /// 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.
203 /// The maximum key length is 255 characters.
204 #[unsafe(method(objectForKey:))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn objectForKey(
207 &self,
208 key: &CKRecordFieldKey,
209 ) -> Option<Retained<ProtocolObject<dyn CKRecordValue>>>;
210
211 #[unsafe(method(setObject:forKey:))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn setObject_forKey(
214 &self,
215 object: Option<&ProtocolObject<dyn CKRecordValue>>,
216 key: &CKRecordFieldKey,
217 );
218
219 #[unsafe(method(allKeys))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn allKeys(&self) -> Retained<NSArray<CKRecordFieldKey>>;
222
223 /// A special property that returns an array of token generated from all the string field values in the record.
224 ///
225 ///
226 /// These tokens have been normalized for the current locale, so they are suitable for performing full-text searches.
227 #[unsafe(method(allTokens))]
228 #[unsafe(method_family = none)]
229 pub unsafe fn allTokens(&self) -> Retained<NSArray<NSString>>;
230
231 #[unsafe(method(objectForKeyedSubscript:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn objectForKeyedSubscript(
234 &self,
235 key: &CKRecordFieldKey,
236 ) -> Option<Retained<ProtocolObject<dyn CKRecordValue>>>;
237
238 #[unsafe(method(setObject:forKeyedSubscript:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn setObject_forKeyedSubscript(
241 &self,
242 object: Option<&ProtocolObject<dyn CKRecordValue>>,
243 key: &CKRecordFieldKey,
244 );
245
246 /// A list of keys that have been modified on the local CKRecord instance
247 #[unsafe(method(changedKeys))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn changedKeys(&self) -> Retained<NSArray<CKRecordFieldKey>>;
250
251 /// `CKRecord`supports
252 /// `NSSecureCoding.`When you invoke
253 /// `encodeWithCoder:`on a
254 /// `CKRecord,`it encodes all its values. Including the record values you've set.
255 /// If you want to store a
256 /// `CKRecord`instance locally, AND you're already storing the record values locally, that's overkill. In that case, you can use
257 /// `encodeSystemFieldsWithCoder:.`This will encode all parts of a
258 /// `CKRecord`except the record keys / values you have access to via the
259 /// `changedKeys`and
260 /// `objectForKey:`methods.
261 /// If you use
262 /// `initWithCoder:`to reconstitute a
263 /// `CKRecord`you encoded via
264 /// `encodeSystemFieldsWithCoder:,`then be aware that
265 /// - any record values you had set on the original instance, but had not saved, will be lost
266 /// - the reconstituted CKRecord's
267 /// `changedKeys`will be empty
268 ///
269 /// # Safety
270 ///
271 /// `coder` possibly has further requirements.
272 #[unsafe(method(encodeSystemFieldsWithCoder:))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn encodeSystemFieldsWithCoder(&self, coder: &NSCoder);
275
276 #[cfg(feature = "CKReference")]
277 /// The share property on a record can be set by creating a share using
278 ///
279 /// ```text
280 /// -[CKShare initWithRootRecord:]
281 /// ```
282 ///
283 /// .
284 ///
285 /// 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.
286 ///
287 /// Sharing is only supported in zones with the
288 /// `CKRecordZoneCapabilitySharing`capability. The default zone does not support sharing.
289 ///
290 /// If any records have a parent reference to this record, they are implicitly shared alongside this record.
291 ///
292 /// 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
293 /// `CKErrorAlreadyShared`error if you try to share any of that record's parents.
294 ///
295 /// Child records can be shared independently, even if they have a common parent. For example:
296 /// Record A has two child records, Record B and Record C.
297 /// A
298 /// /
299 /// \
300 /// B C
301 ///
302 /// These configurations are supported:
303 /// - Record A part of Share 1, or
304 /// - Record B part of Share 1, or
305 /// - Record C part of Share 1, or
306 /// - Record B part of Share 1, Record C part of Share 2
307 ///
308 /// These configurations are not supported:
309 /// Record A part of Share 1, Record B part of Share 2, or
310 /// -- This is not allowed because Record B would then be in two shares; Share 1 by being Record A's child, and Share 2
311 /// Record A part of Share 1, Record C part of Share 2, or
312 /// -- This is not allowed because Record C would then be in two shares; Share 1 by being Record A's child, and Share 2
313 /// Record A part of Share 1, Record B part of Share 2, Record C part of Share 3
314 /// -- This is not allowed because both Record B and Record C would then each be in two shares.
315 ///
316 /// 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.
317 #[unsafe(method(share))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn share(&self) -> Option<Retained<CKReference>>;
320
321 #[cfg(feature = "CKReference")]
322 /// Use a parent reference to teach CloudKit about the hierarchy of your records.
323 ///
324 ///
325 /// When a record is shared, all children of that record are also shared.
326 ///
327 /// A parent record reference must have
328 /// `CKReferenceActionNone`set. You can create a separate reference with
329 /// `CKReferenceActionDeleteSelf`if you would like your hierarchy cleaned up when the parent record is deleted.
330 ///
331 /// The target of a parent reference must exist at save time - either already on the server, or part of the same
332 /// `CKModifyRecordsOperation`batch.
333 ///
334 /// You are encouraged to set up the
335 /// `parent`relationships as part of normal record saves, even if you're not planning on sharing records at this time.
336 /// 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
337 /// `share`reference.
338 #[unsafe(method(parent))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn parent(&self) -> Option<Retained<CKReference>>;
341
342 #[cfg(feature = "CKReference")]
343 /// Setter for [`parent`][Self::parent].
344 ///
345 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
346 #[unsafe(method(setParent:))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn setParent(&self, parent: Option<&CKReference>);
349
350 /// Convenience wrappers around creating a
351 /// `CKReference`to a parent record. The resulting
352 /// `CKReference`will have
353 ///
354 /// ```text
355 /// referenceAction = CKReferenceActionNone
356 /// ```
357 #[unsafe(method(setParentReferenceFromRecord:))]
358 #[unsafe(method_family = none)]
359 pub unsafe fn setParentReferenceFromRecord(&self, parent_record: Option<&CKRecord>);
360
361 #[cfg(feature = "CKRecordID")]
362 #[unsafe(method(setParentReferenceFromRecordID:))]
363 #[unsafe(method_family = none)]
364 pub unsafe fn setParentReferenceFromRecordID(&self, parent_record_id: Option<&CKRecordID>);
365 );
366}
367
368extern_conformance!(
369 unsafe impl CKRecordValue for NSString {}
370);
371
372extern_conformance!(
373 unsafe impl CKRecordValue for NSNumber {}
374);
375
376extern_conformance!(
377 unsafe impl CKRecordValue for NSArray {}
378);
379
380extern_conformance!(
381 unsafe impl CKRecordValue for NSDate {}
382);
383
384extern_conformance!(
385 unsafe impl CKRecordValue for NSData {}
386);
387
388/// CKRecordValue.
389#[cfg(feature = "CKReference")]
390impl CKReference {
391 extern_methods!();
392}
393
394#[cfg(feature = "CKReference")]
395extern_conformance!(
396 unsafe impl CKRecordValue for CKReference {}
397);
398
399/// CKRecordValue.
400#[cfg(feature = "CKAsset")]
401impl CKAsset {
402 extern_methods!();
403}
404
405#[cfg(feature = "CKAsset")]
406extern_conformance!(
407 unsafe impl CKRecordValue for CKAsset {}
408);
409
410#[cfg(feature = "objc2-core-location")]
411extern_conformance!(
412 unsafe impl CKRecordValue for CLLocation {}
413);
414
415extern_protocol!(
416 /// Formalizes a protocol for getting and setting keys on a CKRecord. Not intended to be used directly by client code
417 ///
418 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordkeyvaluesetting?language=objc)
419 pub unsafe trait CKRecordKeyValueSetting: NSObjectProtocol {
420 #[unsafe(method(objectForKey:))]
421 #[unsafe(method_family = none)]
422 unsafe fn objectForKey(
423 &self,
424 key: &CKRecordFieldKey,
425 ) -> Option<Retained<ProtocolObject<dyn CKRecordValue>>>;
426
427 #[unsafe(method(setObject:forKey:))]
428 #[unsafe(method_family = none)]
429 unsafe fn setObject_forKey(
430 &self,
431 object: Option<&ProtocolObject<dyn CKRecordValue>>,
432 key: &CKRecordFieldKey,
433 );
434
435 #[unsafe(method(objectForKeyedSubscript:))]
436 #[unsafe(method_family = none)]
437 unsafe fn objectForKeyedSubscript(
438 &self,
439 key: &CKRecordFieldKey,
440 ) -> Option<Retained<ProtocolObject<dyn CKRecordValue>>>;
441
442 #[unsafe(method(setObject:forKeyedSubscript:))]
443 #[unsafe(method_family = none)]
444 unsafe fn setObject_forKeyedSubscript(
445 &self,
446 object: Option<&ProtocolObject<dyn CKRecordValue>>,
447 key: &CKRecordFieldKey,
448 );
449
450 #[unsafe(method(allKeys))]
451 #[unsafe(method_family = none)]
452 unsafe fn allKeys(&self) -> Retained<NSArray<CKRecordFieldKey>>;
453
454 #[unsafe(method(changedKeys))]
455 #[unsafe(method_family = none)]
456 unsafe fn changedKeys(&self) -> Retained<NSArray<CKRecordFieldKey>>;
457 }
458);
459
460/// CKRecordKeyValueSettingConformance.
461impl CKRecord {
462 extern_methods!(
463 /// 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.
464 /// 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.
465 /// All CKRecordValue types can be set here except CKAsset and CKReference.
466 #[unsafe(method(encryptedValues))]
467 #[unsafe(method_family = none)]
468 pub unsafe fn encryptedValues(
469 &self,
470 ) -> Retained<ProtocolObject<dyn CKRecordKeyValueSetting>>;
471 );
472}
473
474extern_conformance!(
475 unsafe impl CKRecordKeyValueSetting for CKRecord {}
476);