objc2_cloud_kit/generated/
CKDatabase.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/ckdatabasescope?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct CKDatabaseScope(pub NSInteger);
15impl CKDatabaseScope {
16    #[doc(alias = "CKDatabaseScopePublic")]
17    pub const Public: Self = Self(1);
18    #[doc(alias = "CKDatabaseScopePrivate")]
19    pub const Private: Self = Self(2);
20    #[doc(alias = "CKDatabaseScopeShared")]
21    pub const Shared: Self = Self(3);
22}
23
24unsafe impl Encode for CKDatabaseScope {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for CKDatabaseScope {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_class!(
33    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckdatabase?language=objc)
34    #[unsafe(super(NSObject))]
35    #[derive(Debug, PartialEq, Eq, Hash)]
36    pub struct CKDatabase;
37);
38
39unsafe impl Send for CKDatabase {}
40
41unsafe impl Sync for CKDatabase {}
42
43extern_conformance!(
44    unsafe impl NSObjectProtocol for CKDatabase {}
45);
46
47impl CKDatabase {
48    extern_methods!(
49        #[unsafe(method(init))]
50        #[unsafe(method_family = init)]
51        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
52
53        #[unsafe(method(new))]
54        #[unsafe(method_family = new)]
55        pub unsafe fn new() -> Retained<Self>;
56
57        #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
58        #[unsafe(method(addOperation:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn addOperation(&self, operation: &CKDatabaseOperation);
61
62        #[unsafe(method(databaseScope))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn databaseScope(&self) -> CKDatabaseScope;
65    );
66}
67
68/// ConvenienceMethods.
69/// Convenience APIs
70///
71///
72/// These calls operate on a single item in the default zone and allow for simple operations.
73/// If you'd like to batch your requests, add dependencies between requests, set priorities, or schedule operations on your own queue, take a look at the corresponding
74/// `CKOperation.`This work is treated as having
75/// `NSQualityOfServiceUserInitiated`quality of service.
76impl CKDatabase {
77    extern_methods!(
78        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
79        /// `CKFetchRecordsOperation`and
80        /// `CKModifyRecordsOperation`are the more configurable,
81        /// `CKOperation`-based alternatives to these methods
82        #[unsafe(method(fetchRecordWithID:completionHandler:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn fetchRecordWithID_completionHandler(
85            &self,
86            record_id: &CKRecordID,
87            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecord, *mut NSError)>,
88        );
89
90        #[cfg(all(feature = "CKRecord", feature = "block2"))]
91        #[unsafe(method(saveRecord:completionHandler:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn saveRecord_completionHandler(
94            &self,
95            record: &CKRecord,
96            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecord, *mut NSError)>,
97        );
98
99        #[cfg(all(feature = "CKRecordID", feature = "block2"))]
100        #[unsafe(method(deleteRecordWithID:completionHandler:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn deleteRecordWithID_completionHandler(
103            &self,
104            record_id: &CKRecordID,
105            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecordID, *mut NSError)>,
106        );
107
108        #[cfg(all(
109            feature = "CKQuery",
110            feature = "CKRecord",
111            feature = "CKRecordZoneID",
112            feature = "block2"
113        ))]
114        /// `CKQueryOperation`is the more configurable,
115        /// `CKOperation`-based alternative to this method
116        /// Queries can potentially return a large number of records, and the server will return those records in batches. This convenience API will only fetch the first batch of results (equivalent to using
117        /// `CKQueryOperationMaximumResults).`If you would like to fetch all results, use
118        /// `CKQueryOperation`and its
119        /// `CKQueryCursor`instead.
120        /// Queries invoked within a
121        /// `sharedCloudDatabase`must specify a
122        /// `zoneID.`Cross-zone queries are not supported in a
123        /// `sharedCloudDatabase`Queries that do not specify a
124        /// `zoneID`will perform a query across all zones in the database.
125        #[unsafe(method(performQuery:inZoneWithID:completionHandler:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn performQuery_inZoneWithID_completionHandler(
128            &self,
129            query: &CKQuery,
130            zone_id: Option<&CKRecordZoneID>,
131            completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<CKRecord>, *mut NSError)>,
132        );
133
134        #[cfg(all(feature = "CKRecordZone", feature = "block2"))]
135        /// `CKFetchRecordZonesOperation`and
136        /// `CKModifyRecordZonesOperation`are the more configurable,
137        /// `CKOperation`-based alternatives to these methods
138        #[unsafe(method(fetchAllRecordZonesWithCompletionHandler:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn fetchAllRecordZonesWithCompletionHandler(
141            &self,
142            completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<CKRecordZone>, *mut NSError)>,
143        );
144
145        #[cfg(all(
146            feature = "CKRecordZone",
147            feature = "CKRecordZoneID",
148            feature = "block2"
149        ))]
150        #[unsafe(method(fetchRecordZoneWithID:completionHandler:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn fetchRecordZoneWithID_completionHandler(
153            &self,
154            zone_id: &CKRecordZoneID,
155            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecordZone, *mut NSError)>,
156        );
157
158        #[cfg(all(feature = "CKRecordZone", feature = "block2"))]
159        #[unsafe(method(saveRecordZone:completionHandler:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn saveRecordZone_completionHandler(
162            &self,
163            zone: &CKRecordZone,
164            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecordZone, *mut NSError)>,
165        );
166
167        #[cfg(all(feature = "CKRecordZoneID", feature = "block2"))]
168        #[unsafe(method(deleteRecordZoneWithID:completionHandler:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn deleteRecordZoneWithID_completionHandler(
171            &self,
172            zone_id: &CKRecordZoneID,
173            completion_handler: &block2::DynBlock<dyn Fn(*mut CKRecordZoneID, *mut NSError)>,
174        );
175
176        #[cfg(all(feature = "CKSubscription", feature = "block2"))]
177        /// `CKFetchSubscriptionsOperation`and
178        /// `CKModifySubscriptionsOperation`are the more configurable,
179        /// `CKOperation`-based alternative to these methods
180        #[unsafe(method(fetchSubscriptionWithID:completionHandler:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn fetchSubscriptionWithID_completionHandler(
183            &self,
184            subscription_id: &CKSubscriptionID,
185            completion_handler: &block2::DynBlock<dyn Fn(*mut CKSubscription, *mut NSError)>,
186        );
187
188        #[cfg(all(feature = "CKSubscription", feature = "block2"))]
189        #[unsafe(method(fetchAllSubscriptionsWithCompletionHandler:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn fetchAllSubscriptionsWithCompletionHandler(
192            &self,
193            completion_handler: &block2::DynBlock<
194                dyn Fn(*mut NSArray<CKSubscription>, *mut NSError),
195            >,
196        );
197
198        #[cfg(all(feature = "CKSubscription", feature = "block2"))]
199        #[unsafe(method(saveSubscription:completionHandler:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn saveSubscription_completionHandler(
202            &self,
203            subscription: &CKSubscription,
204            completion_handler: &block2::DynBlock<dyn Fn(*mut CKSubscription, *mut NSError)>,
205        );
206
207        #[cfg(all(feature = "CKSubscription", feature = "block2"))]
208        #[unsafe(method(deleteSubscriptionWithID:completionHandler:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn deleteSubscriptionWithID_completionHandler(
211            &self,
212            subscription_id: &CKSubscriptionID,
213            completion_handler: &block2::DynBlock<dyn Fn(*mut CKSubscriptionID, *mut NSError)>,
214        );
215    );
216}