objc2_cloud_kit/generated/CKRecordZone.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
10/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordzonecapabilities?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct CKRecordZoneCapabilities(pub NSUInteger);
15bitflags::bitflags! {
16 impl CKRecordZoneCapabilities: NSUInteger {
17/// This zone supports `CKFetchRecordZoneChangesOperation`
18 #[doc(alias = "CKRecordZoneCapabilityFetchChanges")]
19 const FetchChanges = 1<<0;
20/// Batched changes to this zone happen atomically
21 #[doc(alias = "CKRecordZoneCapabilityAtomic")]
22 const Atomic = 1<<1;
23/// Records in this zone can be shared
24 #[doc(alias = "CKRecordZoneCapabilitySharing")]
25 const Sharing = 1<<2;
26/// This zone supports a single `CKShare` record that shares all records in the zone
27 #[doc(alias = "CKRecordZoneCapabilityZoneWideSharing")]
28 const ZoneWideSharing = 1<<3;
29 }
30}
31
32unsafe impl Encode for CKRecordZoneCapabilities {
33 const ENCODING: Encoding = NSUInteger::ENCODING;
34}
35
36unsafe impl RefEncode for CKRecordZoneCapabilities {
37 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordzoneencryptionscope?language=objc)
41// NS_ENUM
42#[repr(transparent)]
43#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44pub struct CKRecordZoneEncryptionScope(pub NSInteger);
45impl CKRecordZoneEncryptionScope {
46 /// Zone uses per-record encryption keys for any encrypted values on a record or share.
47 ///
48 /// This is the default encryption scope for a record zone.
49 #[doc(alias = "CKRecordZoneEncryptionScopePerRecord")]
50 pub const PerRecord: Self = Self(0);
51 /// Zone uses per-zone encryption keys for encrypted values across all records and the zone-wide share, if present.
52 ///
53 /// This is an optional optimization that can reduce the overall storage used by encryption keys in a zone.
54 /// Note that:
55 /// - Record zones using per-zone encryption only support zone-wide sharing.
56 /// - Encryption scope can only be assigned at zone creation and cannot be changed for the lifetime of the zone.
57 /// - The server will not return zones using per-zone encryption to device OS versions older than the corresponding API availability version.
58 /// - An older OS trying to overwrite an existing zone using per-zone encryption due to a naming collision will result in a `.serverRejectedRequest` error.
59 /// - On device OS upgrade, your application is responsible for fetching database changes via `CKFetchDatabaseChangesOperation` with a nil sync token to ensure it has
60 /// received all the zones available to it from the server.
61 #[doc(alias = "CKRecordZoneEncryptionScopePerZone")]
62 pub const PerZone: Self = Self(1);
63}
64
65unsafe impl Encode for CKRecordZoneEncryptionScope {
66 const ENCODING: Encoding = NSInteger::ENCODING;
67}
68
69unsafe impl RefEncode for CKRecordZoneEncryptionScope {
70 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
71}
72
73extern "C" {
74 /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordzonedefaultname?language=objc)
75 pub static CKRecordZoneDefaultName: &'static NSString;
76}
77
78extern_class!(
79 /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordzone?language=objc)
80 #[unsafe(super(NSObject))]
81 #[derive(Debug, PartialEq, Eq, Hash)]
82 pub struct CKRecordZone;
83);
84
85extern_conformance!(
86 unsafe impl NSCoding for CKRecordZone {}
87);
88
89extern_conformance!(
90 unsafe impl NSCopying for CKRecordZone {}
91);
92
93unsafe impl CopyingHelper for CKRecordZone {
94 type Result = Self;
95}
96
97extern_conformance!(
98 unsafe impl NSObjectProtocol for CKRecordZone {}
99);
100
101extern_conformance!(
102 unsafe impl NSSecureCoding for CKRecordZone {}
103);
104
105impl CKRecordZone {
106 extern_methods!(
107 #[unsafe(method(defaultRecordZone))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn defaultRecordZone() -> Retained<CKRecordZone>;
110
111 #[unsafe(method(init))]
112 #[unsafe(method_family = init)]
113 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
114
115 #[unsafe(method(new))]
116 #[unsafe(method_family = new)]
117 pub unsafe fn new() -> Retained<Self>;
118
119 #[unsafe(method(initWithZoneName:))]
120 #[unsafe(method_family = init)]
121 pub unsafe fn initWithZoneName(
122 this: Allocated<Self>,
123 zone_name: &NSString,
124 ) -> Retained<Self>;
125
126 #[cfg(feature = "CKRecordZoneID")]
127 #[unsafe(method(initWithZoneID:))]
128 #[unsafe(method_family = init)]
129 pub unsafe fn initWithZoneID(
130 this: Allocated<Self>,
131 zone_id: &CKRecordZoneID,
132 ) -> Retained<Self>;
133
134 #[cfg(feature = "CKRecordZoneID")]
135 #[unsafe(method(zoneID))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn zoneID(&self) -> Retained<CKRecordZoneID>;
138
139 /// Capabilities on locally-created record zones are not valid until the record zone is saved. Capabilities on record zones fetched from the server are valid.
140 #[unsafe(method(capabilities))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn capabilities(&self) -> CKRecordZoneCapabilities;
143
144 #[cfg(feature = "CKReference")]
145 /// The share property on a record zone will only be set on zones fetched from the server and only if a
146 /// corresponding zone-wide share record for the zone exists on the server.
147 ///
148 /// You can create a zone-wide share for a zone using `-[CKShare initWithRecordZoneID:]`.
149 ///
150 /// Zone-wide sharing is only supported in zones with the `CKRecordZoneCapabilityZoneWideSharing` sharing capability.
151 /// You cannot share a zone if it already contains shared records.
152 #[unsafe(method(share))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn share(&self) -> Option<Retained<CKReference>>;
155
156 /// The encryption scope determines the granularity at which encryption keys are stored within the zone.
157 ///
158 /// Zone encryption scope defaults to `CKRecordZoneEncryptionScopePerRecord` and can only be modified before zone creation. Attempting to change the encryption
159 /// scope of an existing zone is invalid and will result in an error.
160 ///
161 /// Zones using `CKRecordZoneEncryptionScopePerZone` can only use zone-wide sharing and are not compatible with older device OS versions. Refer to `CKRecordZoneEncryptionScope` for more info.
162 #[unsafe(method(encryptionScope))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn encryptionScope(&self) -> CKRecordZoneEncryptionScope;
165
166 /// Setter for [`encryptionScope`][Self::encryptionScope].
167 #[unsafe(method(setEncryptionScope:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn setEncryptionScope(&self, encryption_scope: CKRecordZoneEncryptionScope);
170 );
171}